Change NULL values in Datetime format to empty string

前端 未结 10 1486
鱼传尺愫
鱼传尺愫 2021-01-07 16:50

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



        
10条回答
  •  离开以前
    2021-01-07 17:18

    declare @mydatetime datetime
    set @mydatetime = GETDATE() -- comment out for null value
    --set @mydatetime = GETDATE()
    
    select 
    case when @mydatetime IS NULL THEN ''
    else convert(varchar(20),@mydatetime,120)
    end as converted_date
    

    In this query, I worked out the result came from current date of the day.

提交回复
热议问题