DB2 graphic  QMF Version 8

Using durations to represent date/time intervals

A duration is a number that represents an interval of time. The number can be a constant, a column name, a function, or an expression.

A duration represents any number of years, months, days, hours, minutes, seconds, or microseconds. The unit is expressed by a keyword that follows the number. In the expression STARTD+25 YEARS, the duration is 25 YEARS.

You can use a duration only in an expression that involves a date or time value. For example, STARTD+25 YEARS+1 MONTH is a valid expression. (STARTD is a column in Q.PROJECT that gives the start date of a project.) STARTD+(25 YEARS+1 MONTH) is not a valid expression, because (25 YEARS+1 MONTH) does not include a date or time value within the parentheses.

YEAR(ENDD - STARTD) < 3 YEARS is not valid because you cannot use the duration, 3 YEARS, as an operand of comparison. A valid way of coding this is YEAR(ENDD - STARTD) < 3.

Subtracting one date from another date results in a duration that is expressed by the number of years, months, and days. Subtracting one time from another time results in a duration that is expressed in the number of hours, minutes, and seconds. See Subtracting dates and Subtracting times for the exact format of these results.


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