ODBC Server Reference Manual
CORE SQL Language
HP NonStop ODBC Server Reference Manual—429151-002
3-19
Functions
interval
is the interval by which timestamp-exp2 is greater than timestamp-exp1. Valid
values of interval are the following 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).
timestamp-exp1
is the first timestamp expression in the comparison. It is the name of a column; the
result of another scalar function; or a time, date, or timestamp literal.
timestamp-exp2
is the second timestamp expression in the comparison. It is the name of a column. The
date portion of this timestamp is set to the current date before the resulting timestamp
is calculated.
If either timestamp expression 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 either timestamp expression is a date value and interval is fractional seconds,
seconds, minutes, or hours; the time portion of that timestamp expression is set to 0
before the resulting timestamp is calculated.
The following SQL statement returns the names of employees and the number of years
they have been employed:
select name, {fn timestampdiff (SQL_TSI_YEAR,
{ fn curdate() }, hire_date)} from employees
YEAR
The YEAR function has the following syntax:
The YEAR function returns the current date.
YEAR ( date-expression )