The SIGN/DECODE combination is also helpful for numeric comparisons e.g. The date example above could be modified as follows: DECODE(SIGN(date1-date2), 1, date2, date1) Helpful Tip #1: One of our viewers suggested combining the SIGN function with the DECODE function as follows: The formula below would equal 0, if date1 is greater than date2: (date1 - date2) - ABS(date1 - date2) Otherwise, the DECODE function should return date1.Īnswer: To accomplish this, use the DECODE function as follows: DECODE((date1 - date2) - ABS(date1 - date2), 0, date2, date1) Question: One of our viewers wanted to know how to use the DECODE function to compare two dates (ie: date1 and date2), where if date1 > date2, the DECODE function should return date2.