sql server - sql case statement with date values -
i have date column in database table.
select sdestructiondate tbldocumentheader
below result of above query
i need print empty date value '1991-01-01'
i expect result set below.
i tried below query still print '1991-01-01' date.
select case convert(date,h.sdestructiondate,103) when '01/01/1991' '' else convert(date,h.sdestructiondate,103) end 'sdestructiondate' tbldocumentheader h
i don't want convert result varchar value. below query gives me result need return date format.
select case convert(varchar,h.sdestructiondate,103) when '01/01/1991' '' else convert(varchar,h.sdestructiondate,103) end 'sdestructiondate' tbldocumentheader h
i first convert null:
select case when h.sdestructiondate = '01/01/1991' null else h.sdestructiondate end sdestructiondate tbldocumentheader h
then reporting tool present blank if value null
mixing data presentation mistake. approach simple , keeps 2 concerns of data , rendering separate.
Comments
Post a Comment