开发者

IF there is 24 hours between dates CASE statment

开发者 https://www.devze.com 2023-01-11 07:01 出处:网络
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

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

精彩评论

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