Can’t figure out why I get the error
substring(cast(CASE WHEN l.assigned IS
NOT NULL THEN l.assigned ELSE
l2.assigned END), 0, 17) as [TEST1]
UPDATED:
The original line I was trying to tweak is the following…wanted to take out that convert because I don’t want that format for the datetime:
, else substring(convert(varchar,
cast(CASE WHEN l.assigned IS NOT NULL
THEN l.assigned ELSE l2.assigned END
as datetime), 126), 0, 17) end) as
varchar(20)) as [TEST1]
Also I tried this which I forgot to mention
substring(cast(CASE WHEN l.assigned IS
NOT NULL THEN l.assigned ELSE
l2.assigned as datetime END), 0, 17)
as [TEST1]
Error: Incorrect syntax near the keyword ‘as’.
You get an error because you didn’t specify a data-type as detailed here. The syntax goes something like this:
You can more simply express your query using isnull (or coalesce) and left. Keep in mind that unless you’re looking for a specific datetime format, you can just do the following: