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)
 IST Date

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2014-08-25 : 09:17:22
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
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-08-25 : 10:05:04
[code]SELECT COUNT(*) FROM YourTable WHERE CAST(Row_Date AS Time) >= '17:30' AND CAST(Row_Date AS Time) <= '18:30'[/code]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
   

- Advertisement -