In DB2 mode and XDB mode, when one timestamp is subtracted from another, the result is a timestamp duration that indicates the number of years, months, days, hours, minutes, and seconds. The data type of the result is DECIMAL(20).
The rules that apply to timestamp subtraction are as follows:
Using the operation RESULT = TS1 - TS2, these rules can be illustrated as follows:
If MICROSECOND(TS2) <= MICROSECOND(TS1) Then MICROSECOND(RESULT) = MICROSECOND(TS1) - MICROSECOND(TS2) If MICROSECOND(TS2) > MICROSECOND(TS1) Then MICROSECOND(RESULT) = 1000000 + MICROSECOND(TS1) - MICROSECOND(TS2) And SECOND(TS2) is incremented by 1