Choose where you’d like to start



The totalMonths() function takes startDateTimeValue and endDateTimeValue as arguments. It returns the number of months between the given date-time values.

Note: The difference between totalMonths function and monthsBetween function is that the monthsBetween function considers a month as 30 days.

For example, let's say the start date is specified as 01-Feb-2019 and the end date is specified as 01-Mar-2019. The February month of 2019 contains 28 days and hence the number of days between the specified dates is 28 which is lesser than 30. Therefore, the monthsBetween function returns 0 and the totalMonths function returns 1. This is because the monthsBetween function considers that a month always contains 30 days whereas the totalMonths function considers a month depending on the number of days in it.

Return Type

  • Number


<variable> = <startDateTimeValue>.totalMonths(<endDateTimeValue>);


<variable> = totalMonths(<startDateTimeValue>, <endDateTimeValue>);


ParameterData typeDescription
<variable>NUMBERVariable which will contain the returned number.

The starting date-time value.


The ending date-time value.


The time value is not taken into account while using this function.

Please refer this help document to learn about the supported date-time formats.


startDate = '31-Dec-1989'; 
endDate = '01-Jan-1990'; 
newEndDate = '01-Feb-1990'; 
numberOfMonths = totalMonths(startDate,endDate);            // returns 0 
numOfMonths = totalMonths(startDate,newEndDate);           // returns 1 
startDate = '01-Feb-2020'; 
endDate = '01-Mar-2020'; 
info totalMonths(startDate,endDate);           // returns 1

Get Started Now