Example: RDIFF Function - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

RDIFF is used to find the right difference of the first Period expression with the second Period expression.

Assume the query runs on the following employee table where period1 and period2 are PERIOD(DATE) columns:

SELECT ename, period2 RDIFF period1 FROM employee;

The employee table contains:

ename   period1                        period2
-----   ----------------------------   ----------------------------
Adams   ('2005-02-03', '2006-02-03')   ('2005-02-03', '2006-02-03')
Mary    ('2005-04-02', '2006-01-03')   ('2005-02-03', '2006-02-03')
Jones   ('2001-01-02', '2003-03-05')   ('2002-03-05', '2004-10-07')
Randy   ('2006-01-02', '2007-03-05')   ('2004-03-07', '2005-10-07')
Simon   ?                              ('2005-02-03', '2005-07-27')

The result is:

ename   (period2 RDIFF period1)
-----   ----------------------------
Adams   ?
Mary    ('2006-01-03', '2006-02-03')
Jones   ('2003-03-05', '2004-10-07')
Randy   ?
Simon   ?