SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
E-29
Considerations—EXTEND
[start-date-time TO ] end-date-time
is a range of DATETIME fields (for example, YEAR TO DAY). If the range is not
specified, the system uses YEAR TO FRACTION(6).
Considerations—EXTEND
Any fields in date-time-expression that are not in the specified range are
truncated.
If the range contains fields to the left of the fields in date-time-expression, the
additional fields receive values based on the current date or time. If the result is not
a valid DATETIME value, an SQL error is generated.
If the range contains fields to the right of the fields in date-time-expression, the
additional fields are initialized:
Examples—EXTEND
In this example, the fields DAY, HOUR, MINUTE, SECOND, and FRACTION to the
right of MONTH are initialized to 01 (for DAY), 00 (for HOUR, MINUTE, and
SECOND) and 000000 (for FRACTION):
EXTEND (DATETIME "1994-11" YEAR TO MONTH , YEAR TO FRACTION)
The function returns the value:
1994-11-01:00:00:00.000000
In this example, the field YEAR to the left of MONTH is initialized to the current
year. The HOUR and MINUTE fields to the right of MONTH are initialized to 0:
EXTEND ( DATETIME "11-24" MONTH TO DAY , YEAR TO MINUTE )
In 1994, the function returns the value:
1994-11-24:00:00
Field Initial Value
MONTH 01
DAY 01
HOUR 00
MINUTE 00
SECOND 00
FRACTION 000000