declare @a table (dte smalldatetime)
insert into @a
select '2007-01-01' union
select '1900-01-01' union
select '2008-01-01'
select dte, datediff(dd, dte, getdate()) diff from @a
-kaht
Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B> bites again.[/small]
SWitch getdate() and dte if you want a positive number of days for dates in dte that are in the future.
Of course if some of the dates might have already happened and you don't want to return a negative number, you will want a where clause
Code:
where getdate()<dte
"NOTHING is more important in a database than integrity." ESquared
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.