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 strongm 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
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
 
How you do this will depend on the RDBMS you are using.<br><br>If you are using Oracle, you could try:<br><br>SELECT * <br>FROM my_table<br>WHERE<br>date_stamp BETWEEN to_date('APR 3 2000','MON DD YYYY') and to_date('APR 10 2000','MON DD YYYY')<br>AND<br>to_number(to_char(date_stamp,'HH24MI')) BETWEEN 1500 and 2300;<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top