开发者

IF there is 24 hours between dates CASE statment

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.....开发者_开发百科


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


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


SELECT CASE WHEN CAST(d1-d2 AS FLOAT) > 1 THEN '> 1 Day' ELSE '<= Day' END
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜