Example: Returning the Interval Value of a Derived Period - Analytics Database - Teradata Vantage

SQL Date and Time Functions and Expressions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-10-30
dita:mapPath
cpk1628111786971.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
pxz1544241488545
lifecycle
latest
Product Category
Teradata Vantageā„¢

INTERVAL returns the interval value 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);

When the following values are inserted into the employee table:

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

the following SQL statement:

SELECT INTERVAL(jobduration)MONTH(4) FROM employee;

returns:

    INTERVAL(jobduration) MONTH
  -----------------------------
                             16