NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
E-31
EXTEND Function
The following SQLCI example uses the UNITS clause to convert a date-time field
to a numeric field:
>> SELECT START_DATE UNITS MONTH FROM PROJECTS;
(EXPR)
------
2
1
2
10
10
--- 5 row(s) selected.
The following programmatic example adds 10 years to the start date and stores the
result in a DATETIME variable. The statement uses the UNITS clause to convert a
numeric 10 to a value of type INTERVAL YEAR.
EXEC SQL SELECT STARTDATE + 10 UNITS YEAR
INTO :NEWDATE TYPE AS DATETIME YEAR TO MINUTE
FROM PROJECTS WHERE PROJECTNAME = '920';
EXTEND Function
EXTEND is a function that adjusts the range of fields for a date-time value to a
specified range or to the default range of DATETIME fields.
It returns a value of type DATETIME.
date-time-expression
is an expression that evaluates to a value of type DATETIME, DATE, TIME, or
TIMESTAMP.
[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.
EXTEND ( date-time-expression
[ , [start-date-time TO ]end-date-time] )