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!

Selecting records, filter by current time and current time minus 5 min

Status
Not open for further replies.

mitchelt

Technical User
Jul 30, 2001
21
US
Hi,

What I am trying to do in (ASP MSSQL) is to query records by the time submitted as compared to the current time and the current time minus 5 minutes.

The time for the records is captured in this format: HHMMSS into a field called TIMESUBMIT

So if the current time is 7:00:00AM the query would be:

Select records where TIMESUMBIT is => than 065500 and TIMESUBMIT <= 070000

I just can't figure out the correct syntax...can some help?

Thanks,

Mitch
 
try something like this:

Code:
SELECT records FROM mytable 
WHERE 
DATEDIFF(n, getdate(), TIMESUMBIT)
BETWEEN 0 AND 5

you may also look into some CONVERT() functions if this doesnt work

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top