HP Neoview SQL Reference Manual page 263

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

Operands
Date – Date
Time + Interval or Interval + Time
Time + Numeric or Numeric + Time
Time - Number
Time – Interval
Timestamp + Interval or Interval + Timestamp
Timestamp + Numeric or Numeric + Timestamp
Timestamp - Numeric
Timestamp – Interval
year-month Interval + year-month Interval
day-time Interval + day-time Interval
year-month Interval – year-month Interval
day-time Interval – day-time Interval
Time – Time
Timestamp – Timestamp
Interval * Number or Number * Interval
Interval / Number
Interval – Interval or Interval + Interval
When using these operations, note:
If you subtract a datetime value from another datetime value, both values must have the
same data type. To get this result, use the CAST expression. For example:
CAST (ship_timestamp AS DATE) - start_date
If you subtract a datetime value from another datetime value, and you specify the interval
qualifier, you must allow for the maximum number of digits in the result for the precision.
For example:
(CURRENT_TIMESTAMP - ship_timestamp) DAY(4) TO SECOND(6)
If you are updating a value that is the result of adding or subtracting two interval values,
an SQL error occurs if the source value does not fit into the target column's range of interval
fields. For example, this expression cannot replace an INTERVAL DAY column:
INTERVAL '1' MONTH + INTERVAL '7' DAY
If you multiply or divide an interval value by a numeric value expression, Neoview SQL
converts the interval value to its least significant subfield and then multiplies or divides it
by the numeric value expression. The result has the same fields as the interval that was
multiplied or divided. For example, this expression returns the value 5-02:
INTERVAL '2-7' YEAR TO MONTH * 2
Examples of Interval Value Expressions
The PROJECT table consists of five columns using the data types NUMERIC, VARCHAR, DATE,
TIMESTAMP, and INTERVAL DAY. Suppose that you have inserted values into the PROJECT
table. For example:
INSERT INTO persnl.project
VALUES (1000,'SALT LAKE CITY',DATE '2007-04-10',
TIMESTAMP '2007-04-21:08:15:00.00',INTERVAL '15' DAY);
Result type
Interval
Time
Time
Time
Time
Timestamp
Timestamp
Timestamp
Timestamp
year-month Interval
day-time Interval
year-month Interval
day-time Interval
Interval
Interval
Interval
Interval
Interval
Expressions
263

Advertisement

Table of Contents
loading

Table of Contents