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 2005 Forums
 Transact-SQL (2005)
 help with TimeStamp query

Author  Topic 

gmunky
Starting Member

5 Posts

Posted - 2007-04-04 : 15:05:30
I'm working with a table with records that contain dates in this
format: (YYYY-MM-DD hh:ii:ss). I need to be able to retrieve records
that are between two given dates(begin date & end date):

let's say the given dates are
begin date: 2007-03-22 15:00:00
end date: 2007-03-23 23:00:00

I want to be able to retrieve the records that satisfy the date range.

example:

Date
--------------------
2007-03-22 13:30:00
2007-03-23 09:30:00
2007-03-23 13:30:00
2007-03-23 15:30:00
2007-03-26 13:30:00


i want the records that have these dates :

2007-03-23 09:30:00
2007-03-23 13:30:00
2007-03-23 15:30:00


Thanks for the help!!



SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-04 : 15:07:15
SELECT * FROM Table1
WHERE Date >= '2007-03-22 15:00:00' AND Date < '2007-03-23 23:00:00'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-05 : 01:00:50
or

between '2007-03-22 15:00:00' AND '2007-03-23 23:00:00'


Madhivanan

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

- Advertisement -