Hi Cheeli,
according to the manuals "IF the THEN/ELSE clause expressions contain a DateTime or Interval data type then all of the THEN/ELSE clause expressions must have the same data type."
So there will be an automatic (implicit) typecast and the rule for comparing DATE and TIMESTAMP is "The TIMESTAMP value is always converted to DATE in case of comparison."
When i first noticed this rule i didn't find it very intuitive:
SELECT 'true' WHERE CURRENT_DATE = CURRENT_TIMESTAMP;
As a rule of thumb: When you have DATE and TIMESTAMP in a comparison/CASE you have to CAST the DATE to a TIMESTAMP explicitly.
In your case the optimizer seems to do the automatic typecast first and then applies the algorithm to simplify the expression and removes the FALSE part.
Hi Cheeli,
according to the manuals "IF the THEN/ELSE clause expressions contain a DateTime or Interval data type then all of the THEN/ELSE clause expressions must have the same data type."
So there will be an automatic (implicit) typecast and the rule for comparing DATE and TIMESTAMP is "The TIMESTAMP value is always converted to DATE in case of comparison."
When i first noticed this rule i didn't find it very intuitive:
SELECT 'true' WHERE CURRENT_DATE = CURRENT_TIMESTAMP;
As a rule of thumb: When you have DATE and TIMESTAMP in a comparison/CASE you have to CAST the DATE to a TIMESTAMP explicitly.
In your case the optimizer seems to do the automatic typecast first and then applies the algorithm to simplify the expression and removes the FALSE part.
Dieter