ODBC Server Reference Manual

CORE SQL Language
HP NonStop ODBC Server Reference Manual429151-002
3-18
Functions
interval
is the interval to be added to the timestamp. It is one of the following INTERVAL
keywords:
SQL_TSI_FRAC_SECOND
SQL_TSI_SECOND
SQL_TSI_MINUTE
SQL_TSI_HOUR
SQL_TSI_DAY
SQL_TSI_MONTH
SQL_TSI_YEAR
Fractional seconds are expressed in millionths of a second (microseconds).
integer-exp
is the number of intervals to be added. It is the name of a column, the result of another
scalar function, or a numeric literal to be added to timestamp-exp.
timestamp-exp
is the timestamp to be incremented. It is the name of a column; the result of another
scalar function; or a time, date, or timestamp literal.
If timestamp-exp is a time value and interval is days, weeks, months, quarters,
or years; the data portion of timestamp-exp is set to the current date before the
resulting timestamp is calculated.
If timestamp-exp is a date value and interval is fractional seconds, seconds,
minutes, or hours, the time portion of timestamp-exp is set to 0 before the resulting
timestamp is calculated.
The following SQL statement returns the names of employees and their one-year
anniversary dates:
select name, {fn timestampadd (SQL_TSI_YEAR, 1, hire_date )}
from employees
TIMESTAMPDIFF
The TIMESTAMPDIFF function has the following syntax:
TIMESTAMPDIFF returns the number of intervals by which one time is greater than
another time.
TIMESTAMPDIFF ( interval, timestamp-exp1, timestamp-exp2 )