Previous Topic: Special RegistersNext Topic: Expressions without Arithmetic Operators


Labeled Duration

A labeled duration represents any number of years, months, days, hours, minutes, seconds, or microseconds. This number is then converted as if it were assigned to a DECIMAL(15,0). The unit is expressed by a keyword following the number. For example, 25 YEARS is the labeled duration in HIREDATE + 25 YEARS.

A labeled duration can only be used in an expression that involves a date or time value. For example:

HIREDATE + 25 YEARS + 1 MONTH is valid, but

HIREDATE + (25 YEARS + 1 MONTH) is not valid.

Following is the syntax diagram for labeled durations.

Note: Labeled duration, this is a CA Datacom/DB extension.

►►─┬─ function ──────┬─┬─ DAY ──────────┬─────────────────────────────────────►◄
   ├─ (expression) ──┤ ├─ DAYS ─────────┤
   ├─ literal ───────┤ ├─ HOUR ─────────┤
   ├─ column-name ───┤ ├─ HOURS ────────┤
   └─ host-variable ─┘ ├─ MICROSECOND ──┤
                       ├─ MICROSECONDS ─┤
                       ├─ MINUTE ───────┤
                       ├─ MINUTES ──────┤
                       ├─ MONTH ────────┤
                       ├─ MONTHS ───────┤
                       ├─ SECOND ───────┤
                       ├─ SECONDS ──────┤
                       ├─ YEAR ─────────┤
                       └─ YEARS ────────┘
function

Specify a function. For more information about functions, see Functions.

(expression)

Specify an expression. For more information about expressions, see Expressions.

literal

Specify a literal. If the expression is numeric, the literal must be numeric. For more information on literals, see Literals.

column-name

Specify the name of a column in a table or view. If the expression is an arithmetic expression, the column must be of a numeric data type.

host-variable

Specify a host-variable. A host-variable in an expression must identify a variable described in the program under the rules for declaring host-variables. For more information on host-variables, see Host Variables.

DAY/DAYS

A duration expressed in day(s). For more information on durations, see Durations.

HOUR/HOURS

A duration expressed in hour(s). For more information on durations, see Durations.

MICROSECOND/MICROSECONDS

A duration expressed in microsecond(s). For more information on durations, see Durations.

MINUTE/MINUTES

A duration expressed in minute(s). For more information on durations, see Durations.

MONTH/MONTHS

A duration expressed in month(s). For more information on durations, see Durations.

SECOND/SECONDS

A duration expressed in second(s). For more information on durations, see Durations.

YEAR/YEARS

A duration expressed in year(s). For more information on durations, see Durations.