views:

53

answers:

3

I am trying to create a case statment saying if 1 day or less has passed between my 2 date parameters then do this otherwise do this.....

+4  A: 

Try this, however this only works in a query

case when datediff(hh,@Date1,@Date2) < 24 then.....

if it is in regular non query T-SQL just use an IF statement

IF datediff(hh,@Date1,@Date2) < 24  
begin
-- stuff here
end
else
begin
-- stuff here
end
SQLMenace
+1  A: 

Explain "do this", because a CASE expression doesn't control flow.

OMG Ponies
+1  A: 
SELECT CASE WHEN CAST(d1-d2 AS FLOAT) > 1 THEN '> 1 Day' ELSE '<= Day' END
Martin Smith