如果日期值为空,则转换为返回0 [英] convert to return 0 if date value is null sql

查看:385
本文介绍了如果日期值为空,则转换为返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
我正在尝试关注查询

Hello friends,
I was trying following query

select CONVERT(date, MIN(actiondate)) from tbl_action_history



有什么方法可以检查,如果CONVERT(date, MIN(actiondate))为NULL,那么如何获取值0.

在此先感谢



Is there any way to check, if the CONVERT(date, MIN(actiondate)) is NULL then how to get value 0 as a result.

Thanks in advance

推荐答案

我不清楚要做什么..
但您可以通过这种方式找到..

iam not clear what you want to do..
but your can find in that way..

declare @Check varchar(50)
declare @Result int
select @Check=  CONVERT(date, MIN(actiondate)) from tbl_action_history // Your Condition
if (@Check=null and @Check='''')
begin
set @Result=1
select @Result
end 

else
begin
set @Result=0
select @Result
end


这篇关于如果日期值为空,则转换为返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆