Hello

I am trying to write a case when statement in Informix which consists of string fields and date fields

I understand that I need to have the fields compatible in order for the statement to work correctly.

However I am struggling with the date field. I know I need to convert it to a to_char, but I also want to find it's maximum value, and I think this needs to be in a date format?

The part in red is where I am struggling. I need to find it's maximum value

case when location = 'DOSPR' then to_char(datetime)
when location <> 'DOSPR'
then to_char(Max(to_date(AUD.xta_changedtime, "%m/%d/%iY")))end as test,

Can anyone help me?