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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 IST Date
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

240 Posts

Posted - 08/25/2014 :  09:17:22  Show Profile  Reply with Quote
Hi All,
I have a table where I am storing a transaction as Row_Date.
Now I have create a Hourly report of transaction

Please suggest how to get total rows between 05:30 to 06:30 as I have to run the query in interval of 1 hour starting from 05:30

PLease suggest

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 08/25/2014 :  10:05:04  Show Profile  Reply with Quote
SELECT COUNT(*) FROM YourTable WHERE CAST(Row_Date AS Time) >= '17:30' AND CAST(Row_Date AS Time) <= '18:30'
This is only an example. If you have data for more than one day, this would aggregate all of those. Is that what you want, or do you want to look at the data for each date? Also, you should change it depending it on whether you want the count to be inclusive on both ends - i.e., whether you want to include the data if the time is exactly 17:30 or exactly 18:30.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000