Sunday, July 24, 2011

TO_DATE(NULL)

Wonder why the null needs to be convert to date data type? well, here's the story.

DECODE (BIRTHDATE, TO_DATE('31129999', 'DDMMYYYY'), TO_DATE(NULL), BIRTHDATE)

Simply put, if the birthdate is equal to end of the calendar then put the output as null else show the birthdate. Unfortunately, the SQL code was not accepted because the argument type in the decode function all must the same.

Of course there nothing wrong to convert a null value but nevertheless it looked silly. :-D