Years ago | DATE_YEARS_AGO

Syntax

DATE_YEARS_AGO( [value], [now = CURRENT_DATE()] )

Parameters

value
A DATE value. If the value is not a DATE, it will be converted to one with the DATE operation.

now
A DATE value that specifies the logical current time. If not provided, the current date is used. If the value is not a DATE, it will be converted to one with the DATE operation.

Return Value

The number of full years the VALUE is before NOW.

Description

Determine how many full years ago a DATE is from the current date.

Examples

DATE_YEARS_AGO("2017-08-30T17:36:23.000Z", "2017-08-30T17:36:23.000Z") # returns 0
DATE_YEARS_AGO("2015-08-30T17:36:23.000Z", "2017-08-30T17:36:23.000Z") # returns 2
DATE_YEARS_AGO("2016-08-30T17:36:23.000Z", "2017-07-30T17:36:23.000Z") # returns 0