Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time & date query

Status
Not open for further replies.

marct

Programmer
Apr 6, 1999
32
0
0
US
Hi,<br><br>I need to query a table based on user-chosen time & date. There is three shifts of data being logged on a daily basis, and I need to get, say, a weeks worth of data for a shift.&nbsp;&nbsp;I can't seem to find a way to write the query that will give me, for example, &quot;all records that were logged between Apr 3 2000 and Apr 10 2000, but only between 3:00PM and 11:00PM&quot;. <br><br>I am a novice at SQL, so I could easily be missing something glaringly obvious to you seasoned database gurus.&nbsp;&nbsp;Thanks in advance for any help.<br><br>-Marc
 
<br>Select ...<br>Where logTime BETWEEN '20000403' AND '20000410'<br>And DATEPART(hh,logTime) BETWEEN 15 AND 23<br><br>You'll have to fool with your date format but this should be what you are looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top