15.00 - PRIOR - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)
Last Update
2018-09-24

PRIOR

Purpose  

Returns the preceding value of the argument so that there is one granule of the argument type between the returned value and the argument.

Syntax  

where:

 

Syntax element...

Specifies...

datetime_expression

any expression that evaluates to a DATE, TIME, or TIMESTAMP data type.

Return Value

The return data type is the same as that of the argument. If the value of the argument is NULL, the result is NULL.

Format and Title

The format is the default format for the argument's data type.

Restrictions

The built-in function DATE is not supported as an argument to the PRIOR function. For example, PRIOR(DATE) is no valid. You must use PRIOR(CURRENT_DATE) instead.

Error Conditions

If the argument does not have a DateTime data type, an error is reported.

If the result is outside the permissible range of the argument's data type, an error is reported. For example, if PRIOR(DATE '0001-01-01') is specified, an error is reported.

Example  

Assume the following query is executed on the employee table where period1 is a PERIOD(DATE) column:

   SELECT * 
   FROM employee 
   WHERE PRIOR(END(period1)) = DATE '2004-03-04';
   ename   dept          period1
   -----   -----------   ----------------------------
   Jones   Sales         ('2004-01-02', '2004-03-05')
   Simon   Sales         ?

The result is:

   ename   dept          period1
   -----   -----------   ----------------------------
   Jones   Sales         ('2004-01-02', '2004-03-05')