Skip to main content
Inspiring
June 5, 2009
Question

coalesce Error

  • June 5, 2009
  • 1 reply
  • 1150 views

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 AS

Updated

--, t1.logindate

--, t2.LastLogIn

,COALESCE(COALESCE(t2.LastLogIn, t1.LoginDate),'Never')as [Logged In

]

--, t1.CCFLevelID

--, t2.SecurityLevel_ID

FROM

CCFUser

t1

LEFT OUTER JOIN

User_TBL

t2

ON

t1.First_Name =

t2.first_name

AND

t1.Last_Name = t2.Last_name

WHERE

t1.CCFLevelID IN (2, 4) And t1.Deleted =

0

This topic has been closed for replies.

1 reply

Inspiring
June 5, 2009

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.

emmim44Author
Inspiring
June 5, 2009

you meant to convert to varchar??

Inspiring
June 5, 2009

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')