Skip to main content
Version: Java (Groovy)

diffYearsAvg

diffYearsAvg returns the difference in years (defined as 365.2425 days to compensate for leap years) between two date-time values, as a double.

Syntax

diffYearsAvg(start, end)

Parameters

ParameterTypeDescription
startInstant

The start time of the range.

startZonedDateTime

The start time of the range.

endInstant

The end time of the range.

endZonedDateTime

The end time of the range.

Returns

Returns the difference in years between the supplied start and end values.

Examples

d1 = parseInstant("2022-01-01T00:00:00 ET")
d2 = parseInstant("2028-01-02T00:00:00 ET")

difference = diffYearsAvg(d1, d2)
println difference