Wrox Programmer Forums
|
SQL Server 2005 General 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
 
Old September 25th, 2007, 10:56 AM
Authorized User
 
Join Date: Mar 2004
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Default Time Range Query

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.

thanks
 
Old September 26th, 2007, 06:18 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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)







Similar Threads
Thread Thread Starter Forum Replies Last Post
Time Query divovsky Access 3 July 25th, 2007 06:24 AM
date range query killroy Access 2 August 17th, 2005 02:14 PM
Need to avg time in a query rseward Access 3 December 8th, 2004 05:19 PM
Query with a date range... PLEASE HELP! tlcable7 Access ASP 2 October 1st, 2003 03:41 PM
Time out on insert query Tom_Nguyen SQL Server 2000 0 June 29th, 2003 11:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.