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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting data from 5 minutes ago using DATEDIFF?

Status
Not open for further replies.

Raenius

Programmer
Oct 14, 2003
77
0
0
NL
Hi all,

Currently I am working on a SQL query which I can't seem to get working properly.

I want to gather distinct data from a table with a timestamp of 5 minutes before localtime.

I've gotten so far:
Code:
SELECT DISTINCT ROUTERS.name AS Router_Name
FROM         ROUTERS INNER JOIN
                      PINGS ON ROUTERS.routerID = PINGS.routerID AND ROUTERS.threshold < PINGS.rtt
WHERE     (PINGS.[timestamp] > GETDATE()) -??????

I need to use the DATEDIFF function and gather the data from 5 minutes ago but I really do not have a clue on how to use this function.

Can someone point me in the right direction?

Thanks in advance...

- Raenius

&quot;Free will...is an illusion&quot;
 
Datediff (interval, start, end) returns integer number of time intervals between start and end:
Code:
...
where datediff( mi, PINGS.[timestamp], getdate()) < 5
 
LOL Just before you posted this I found the answer myself..

Anyway thanks for the answer and your time!

- Raenius

ps. Next time I'll do more research for opening a post. Oh well maybe someone else will benefit from this thread ;-)

&quot;Free will...is an illusion&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top