Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Query over two columns

Author  Topic 

macca18
Starting Member

7 Posts

Posted - 2006-05-11 : 09:31:22
Hi,

I have a table that includes two DateTime columns. The first column holds the date. e.g 2006/5/10 and the second column holds time e,g 08:15:25.

I am having a problems specifing a query that will list the rows in the table between a date time range.

i.e return all rows between 2006/5/8 09:00:00 and 2006/5/10 21:30:00

Can anyone give me any suggesstions on how to do this?

Thanks
Macca

nr
SQLTeam MVY

12543 Posts

Posted - 2006-05-11 : 09:42:00
I take it that you mean when displayed they hold
20060510 00:00:00.000
and
19000101 08:15:25.000

select *
from tbl
where coldte + coltme bewtween '20060508 09:00:00' and '20060510 21:30:00'

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-11 : 09:56:33
Why did you use two columns to store date and time seperately?
Hereafter, Use DateTime datatype

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -