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
 General SQL Server Forums
 New to SQL Server Programming
 Query by date and time

Author  Topic 

brianfitz
Starting Member

4 Posts

Posted - 2009-10-08 : 05:45:04
Hi Guys, hope you can help!

Basically I have to run a query on our SQL database and need to get back the rows for September between the times 8.00 and 9.00 and was wondering how I write the syntax?

Unfortunately any query I write comes back blank but without an error so I'm lost!

Our datetime example is 19/02/2008 12:52:00

Can anyone shed any light on this?

Thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-08 : 05:55:50
[code]
where datecol >= '2009-09-01'
and datecol < '2009-10-01'
and datepart(hour, datecol) = 8
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

brianfitz
Starting Member

4 Posts

Posted - 2009-10-08 : 06:16:29
That is absolutely perfect, thank you so much!
Go to Top of Page
   

- Advertisement -