monthsBetween()
Table of Contents
Overview
The monthsBetween() function takes startDateTimeValue and endDateTimeValue as arguments. It returns the number of months between the given date-time values.
Return Type
- Number
Syntax
(OR)
Parameter | Description | Data type |
---|---|---|
<variable> | Variable which will contain the returned number. | NUMBER |
<startDateTimeValue> | The starting date-time value. | DATE-TIME |
<endDateTimeValue> | The ending date-time value. | DATE-TIME |
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.
A runtime error will be encountered in Zoho Creator if:
- the hour value, or minute value, or second value, is specified in more than 2 digits.
- the date value exceeds the number of days in that month.
- an incorrect month value is specified.
- the year value has more than 4 digits.
Examples
endDate = '01-Jan-1990';
newEndDate = '01-Feb-1990';
numberOfMonths= monthsBetween(startDate, endDate); // returns 0
numOfMonths = monthsBetween(startDate, newEndDate); // returns 1
endDate = '01-Mar-2020';
info monthsBetween(startDate, endDate); // returns 0