将NULL值以日期时间格式更改为空字符串 [英] Change NULL values in Datetime format to empty string
问题描述
ISNULL([应计出默认值] ')
这里累积的默认值是datetime类型,它的作用是将null更改为'1900- 01-01 00:00:00.000'而不是空
然后我尝试将它们转换成varchar并应用相同的
ISNULL(CONVERT(varchar(50),[Amort Into Default]),'')
现在我可以转换为空字符串,但现在这些datetime转换为字符串,我需要在datetime
所以我尝试CAST,CONVERT,但不工作。 / p>
CONVERT(Datetime,'ISNULL(CONVERT(varchar(50),[Amort Into Default]),'')',120 )
这给出错误。
是有任何可能的解决方案。
>解决方案你好有人回答这个做。
> ISNULL(CONVERT(varchar(50),[Amort Into Default],120),''),它的作品我不知道为什么。
**
CASE和CAST应该工作:
CASE WHEN mycol IS NULL THEN''ELSE CONVERT(varchar(50 ),mycol,121)END
I have a table which contains 'NULL' values which are of type 'Datetime'. Now i have to convert those into empty string but when when i use convert function
ISNULL( [Accrued Out of Default] ,'' )
here accrued into default is of datetime type, what it does it changes null to '1900-01-01 00:00:00.000' instead of empty
Then i try to convert them into varchar and apply same
ISNULL(CONVERT(varchar(50), [Amort Into Default] ),'')
Now I am able to convert into empty string but now those datetime are converted to string which I needed in datetime So I try to CAST, CONVERT but non of them works.
CONVERT(Datetime,'ISNULL(CONVERT(varchar(50), [Amort Into Default] ),'')',120)
This gives error.
Is there any possible solution to this.
> **Solution Hi someone answered this to do as.
> ISNULL(CONVERT(varchar(50), [Amort Into Default] ,120),'') and it works I dont know why .
**
CASE and CAST should work:
CASE WHEN mycol IS NULL THEN '' ELSE CONVERT(varchar(50), mycol, 121) END
这篇关于将NULL值以日期时间格式更改为空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!