SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

sanjay5219
Posting Yak Master

229 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

3705 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  
 New 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.05 seconds. Powered By: Snitz Forums 2000