Example: Querying for the Number of Months Between Two Dates - Advanced SQL Engine - Teradata Database

SQL Date and Time Functions and Expressions

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
xmd1556127764262.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1211
lifecycle
previous
Product Category
Teradata Vantageā„¢

The following query:

SELECT MONTHS_BETWEEN(DATE'1995-02-02', DATE'1995-01-01'); 

returns the result 1.03225806451612903225806451612903225806. The MONTHS_BETWEEN function calculates the fractional portion of the result based on a 31-day month and considers the difference in time components of date_timestamp_value1 and date_timestamp_value2.