Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

coalesce Error

Participant ,
Jun 05, 2009 Jun 05, 2009

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

TOPICS
Database access
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 05, 2009 Jun 05, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 05, 2009 Jun 05, 2009

you meant to convert to varchar??

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 05, 2009 Jun 05, 2009
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources