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

how to determine if record was last updated 60 min ago

Status
Not open for further replies.

lizok

Programmer
Jan 11, 2001
82
US
Hi

i am trying to write a query that would pull all records from the table where record was last updated 60 min ago and flag them?

aim a little confused with datepart (is that what i use?) to determine was 60 min since the last update?

i'd appreciate any help. (and sample code :))
thank you
liz

 
Do you want records that were updated more than 60 minutes ago, less than 60 minutes or exactly 60 minutes?

Also do you have a field inyour database that stores the date of the last update?

Questions about posting. See faq183-874
 
Code:
Update yourtable
set yourflag = 'Y'
where updatetimefield = dateadd(hh,-1,GETDATE())

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
I am resetting the flag for those users who update their records =60 or more minutes ago.

i have a field "LastUpdateDT" that is set on every page onLoad event.
 
this query doens't pull any records
Update yourtable
set yourflag = 'Y'
where updatetimefield = dateadd(hh,-1,GETDATE())

i have one set to: 12/16/2004 7:30:36 AM and it shdoul have been pulled.
i've tried n,-60- same result- nothing
 
try <= insaead of =

your current query would only give you results that were exactly 60 minutes ago.

Questions about posting. See faq183-874
 
Not only that and to be more specific - it would only give you records that were exactly to the second 60 minutes old.

you may want to convert the times to strip off the seconds so it only matches on minutes or 60 of them ago.

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top