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

DateDiff problem. 2

Status
Not open for further replies.

jcisco

Programmer
Sep 17, 2002
125
US
I have a problem, and i'm not sure really how to slove it. I have a table that has a datetime stamp in it, and what i need to do is get that date time stamp and compair it to the current time.
So I have this.

--@time is the datetime stamp in the table.
set @difference = (datediff(hour, Convert(char(50), getdate(),109), @time))

Now then what i need to do is check to see if the difference is greater than one hour, if it is i'm emailing a group of people (which i have working)
but when i do a print out of the difference it get Jan 1 1900 12:00AM
so how can i say @difference > 1 ?

thanks.

--------------
:)
 
Code:
if datediff(hour,@time,getdate()) > 1
begin
  -- do your stuff
end
 
It looks like you are declaring @difference to be a datetime datatype, not an integer. DATEDIFF returns an integer.

--Angel [rainbow]
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top