Skip to main content
Workday User Guide
Last Updated: 2023-06-23
YEAR_DIFF

YEAR_DIFF

Description

YEAR_DIFF
is a row function that calculates the fractional number of years between two
DATE
values (
date_1
-
date_2
). This function:
  • Calculates elapsed whole years between the start and end dates (
    date_1
    -
    date_2
    ).
  • Calculates the remaining days in the fractional year.
  • Divides the remaining days of fractional year by 365.
  • Adds the fractional year to the elapsed whole years to generate the final result.
    • If there are 365 days remaining in the fractional year and it includes February 29, the application divides the remaining days by 366 to avoid over-calculating and producing a full year when the year is 1 day short.

Syntax

YEAR_DIFF
(
date_1
,
date_2
)

Return Value

Returns one value per row of type
DOUBLE
.

Input Parameters

date_1
Required. A field or expression of type
DATE
.
date_2
Required. A field or expression of type
DATE
.

Examples

Calculate the number of years a user has been a customer by subtracting the value of the
registration_date
field from the current date (the result of the
TODAY
expression):
YEAR_DIFF(TODAY(), [registration_date])
Calculate a user's age by subtracting the value of the
birthdate
field from the current date (the result of the
TODAY
expression):
YEAR_DIFF(TODAY(), [birthdate])