yearsBetween()

yearsBetween()

Overview

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

Note: A year consists of 365 days.

Return Type

  • Number

Syntax

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

(OR)

<variable> = yearsBetween(<startDateTimeValue>,<endDateTimeValue>);
ParameterDescriptionData 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

A runtime error will be encountered 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.
  • Please refer this help document to learn about the supported date-time formats.

Examples

startDate = '1-Jan-2019';
endDate = '31-Dec-2019';
newStartDate = '1-Jan-2020';
newEndDate = '31-Dec-2020';
numberOfYears= yearsBetween(startDate, endDate);                         // returns 0
numOfYears = yearsBetween(newStartDate, newEndDate);               // returns 1

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com