SQL Server 2005General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
I need to get records from a table between certain times. lets say retrieve all the data between 11:30 AM and 1:15 PM of the given date range (for e.g. between 9/15/2007 and 9/24/2007) .
I need to bring the records of each day between those dates and time.
Any suggestions would be appreciated.
SELECT DATEADD(DAY, DATEDIFF(DAY, 0, Col1), 0),
COUNT(*)
FROM Table1
WHERE Col1 >= '20070915' AND Col1 < '20070925'
AND CONVERT(CHAR(8), Col1, 108) BETWEEN '11:30:00' AND '13:14:59'
GROUP BY DATEADD(DAY, DATEDIFF(DAY, 0, Col1), 0)