Copy link to clipboard
Copied
Please input
Error: Conversion failed when converting datetime from character string .... close to the coalesce
SELECT
(t1.First_Name + ' ' + t1.Last_Name + '('+ t1.Work_Status + ')')As Name
,t1.EID
,t1.CSGID
,t1.CCFRole
,t1.CCFLocationID
, t1.ModifyDate ASUpdated
--, t1.logindate
--, t2.LastLogIn
,COALESCE(COALESCE(t2.LastLogIn, t1.LoginDate),'Never')as [Logged In]
--, t1.CCFLevelID
--, t2.SecurityLevel_ID
FROM
CCFUsert1
LEFT OUTER JOIN
User_TBLt2
ON
t1.First_Name =t2.first_name
AND
t1.Last_Name = t2.Last_nameWHERE
t1.CCFLevelID IN (2, 4) And t1.Deleted =0
Copy link to clipboard
Copied
all choices in coalesce have to be the same datatype. use whatever db function is available to you convert the 1st two choices from date to string.
Copy link to clipboard
Copied
you meant to convert to varchar??
Copy link to clipboard
Copied
Different db's have different functions that convert numbers and dates to strings. The names include, cast, to_char, and string. Let's say you are using oracle. You want
coalesce(to_char(date1), to_char(date2), 'never')