DB2 graphic  QMF Version 8

Incrementing and decrementing times by durations

Adding a duration to a time or subtracting a duration from a time results in a time. The next example increments a time by a duration. To find the start time for an interview if the interview starts 2 hours, 30 minutes, and 45 seconds late, use the following SQL statement:

SELECT STARTTIME + 2 HOURS + 30 MINUTES + 45 SECONDS
  FROM Q.INTERVIEW
  WHERE TEMPID = 400

QMF produces this report:

   COL1
   --------
   15.30.45

Adding 24 hours to the time 00.00.00 results in 24.00.00. However, adding 24 hours to any other time results in the same time as the time you are incrementing.

The next example decrements a time by a duration. To find out what time an interview would end if it ended 1 hour, 20 minutes, and 20 seconds early, use the following SQL statement:

SELECT ENDTIME - 1 HOUR - 20 MINUTES - 20 SECONDS
  FROM Q.INTERVIEW
  WHERE TEMPID = 410

QMF produces this report:

   COL1
   --------
   14.57.40


Go to the previous page Go to the next page

Downloads | Library | Support | Support Policy | Terms of use | Feedback
Copyright IBM Corporation 1982,2004 Copyright IBM Corporation 1982, 2004
timestamp Last updated: March, 2004