I have a field called program_start_date that is formatted as YYYYMM. I need to determine if this date occurs 5 years ago or less, if it occurs more than 5 years ago, or if it is blank.
I have the following case statement in my SQL query:
CASE
WHEN floor(MONTHS_BETWEEN(sysdate, program_start_date)/12) <= 5 THEN '5 years or less'
WHEN floor(MONTHS_BETWEEN(sysdate, program_start_date)/12) > 5 THEN '6+ years'
WHEN program_start_date is null THEN 'Blank'
ELSE program_start_date
END
I'm getting the following error message:
ORA-01861: literal does not match format string 01861. 00000 - "literal does not match format string"
*Cause: Literals in the input must be the same length as literals in the format string (with the exception of leading whitespace). If the "FX" modifier has been toggled on, the literal must match exactly, with no extra whitespace.
*Action: Correct the format string to match the literal.
I tried inserting to_date() in the first two cases, but I'm still getting the same error message. How can I resolve this issue?
to_datecall? - Mureinik