Find records produced in the last hour
- by justSteve
I have a smalldatetime field named myTime recording when the record was created. I need the syntax that selects records created within the last hour.
thought it would be:
and DATEDIFF("hh", datePart(hh, myTime), DatePart(hh, GETDATE()) < 1
where datediff
1) looks for hours;
2) looks at the hours portion of the data in myTime as starting;
3) looks at the hours portion of now for ending
3) produces an int that gets compared to '1'
the results i'm getting are clearly way, way off base cuz umm...clearly...i don't know what i'm doing.
help?
thx