October 15, 2009 at 8:50 am
Hi ,
I have a case statement where i am checking for some dates and displaying a number for each date.
When the date is null i need to display #N/A.
CASE
WHEN Convert(varchar(13),column1,112) < date1 THEN 1
WHEN Convert(varchar(13),column1,112) < date2 THEN 2
WHEN Convert(varchar(13),column1,112) < date3 THEN 3
WHEN Convert(varchar(13),column1,112) IS NULL THEN '#N/A' ELSE 4
END AS Grp
The Column1 is actually a datetime.
error: Conversion failed when converting the varchar value '#N/A' to data type int.
Please suggest..
Thanks,
Nemo
October 15, 2009 at 9:45 am
Possible outputs are 1,2,3,4 which are parsed as INT, and 'N/A' which is a string.
Try using '1' instead of 1, '2' instead of 2, etc...
October 15, 2009 at 10:19 am
That works...
Thanks Ben.
October 15, 2009 at 12:09 pm
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply