differenceInMonths

Modified on Tue, 22 Aug 2023

Description

Use this function to get the number of full months between the given dates.

Syntax

differenceInMonths(date1, date2)

Returns

Return ValueDescription
NumberReturn the number of full months between the given dates.

Sample

ExampleResultDescription
differenceInMonths (2022-2-15, 2023-4-3)14In this example, date1 is February 15, 2022, and date2 is April 3, 2023. The differenceInMonths function returns 14, which is the number of full months between the two dates.

To view all the Date functions, click here.

See Also