Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 25th, 2007, 10:56 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old September 26th, 2007, 06:18 AM
Friend of Wrox
 
Join Date: May 2006
Location: Helsingborg, , Sweden.
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)


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:03 AM.


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