15.00 - END - 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

END

Purpose  

Returns the ending bound of the period argument.

Syntax  

where:

 

Syntax element...

Specifies...

period_expression

any expression that evaluates to a Period data type.

derived_period

any expression that evaluates to a derived period.

Return Value

The result data type of the END function is same as the element type of the Period expression or the data type of the end column if the argument is a derived period column. If the argument is NULL, the result is NULL.

Format and Title

The format is the default format for the element type of the Period expression or the format of the end column if the argument is a derived period column.

Error Conditions

If an argument of any data type other than a Period data type is passed to the function, an error is reported.

Example  

Assume the following query:

   SELECT * FROM employee WHERE END(period1) = DATE '2005-01-07';

executes on the employee table with PERIOD(DATE) column period1:

   ename   dept          period1
   -----   -----------   ----------------------------
   Jones   Sales         ('2004-01-02', '2004-01-05')
   Adams   Marketing     ('2004-06-19', '2005-02-09')
   Mary    Development   ('2004-06-19', '2005-01-05')
   Simon   Sales         ('2004-06-22', '2005-01-07')

The result is:

   ename   dept          period1
   -----   -----------   ----------------------------
   Simon   Sales         ('2004-06-22', '2005-01-07')

Example  

END returns the ending bound (jdend) of a derived period called jobduration created using the following SQL statement:

CREATE TABLE employee(id INTEGER,
                      name VARCHAR(50),
                      jdbegin DATE NOT NULL FORMAT 'YYYY-MM-DD',
                      jdend   DATE NOT NULL FORMAT 'YYYY-MM-DD',
                      PERIOD FOR jobduration(jdbegin,jdend)
  )PRIMARY INDEX(id);

The following SQL statements:

INSERT INTO employee(1025,'John',DATE'2011-01-02',DATE'2012-05-02');
SELECT END (jobduration) FROM employee;

return is:

     jdend
__________
2011-05-02