November 7, 2005 at 1:56 pm
I have a table with a colum called lastupdated.
I need to find any records that where updated in the last 2 minutes based on getdate()
the lastupdated column data type is datetime
any help would be appreciated.
thanks
November 7, 2005 at 2:09 pm
CREATE TABLE #TableA (ID int, LastUpdated datetime)
INSERT INTO #TableA VALUES(1, DATEADD(d,-1,getdate()))
INSERT INTO #TableA VALUES(2, DATEADD(mi,-1,getdate()))
SELECT * FROM #TableA WHERE LastUpdated > DATEADD(mi,-2,getdate())
DROP TABLE #TableA
November 7, 2005 at 2:21 pm
SELECT ...
FROM MyTable
WHERE LastUpdated between dateadd(n, -2, GETDATE()) and GETDATE()
_____________
Code for TallyGenerator
November 7, 2005 at 4:00 pm
Thank you, this is what I was trying to don on my own but couldn't.
GF
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply