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

Teradata Vantage™ - SQL Date and Time Functions and Expressions

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1211-171K
Language
English (United States)

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.