Choose where you’d like to start

timeBetween

Overview

The timeBetween function calculates the time difference between two given date-time values.

Note:

  • The difference in represented in HH:mm:ss format. HH: in case of differences in just the hour. HH:mm: in case of differences in just the hour and minute.
  • End time has to be greater than start time.

Return Type

Syntax

<variable> = <start_time>.timeBetween(<end_time>);

where,

ParameterData typeDescription
<variable>TEXTVariable which will contain the difference in time.
<start_time>DATE-TIME/TEXTThe time from which time difference should be calculated.
<end_time>DATE-TIME/TEXTThe time upto which time difference should be calculated.

Following are to be considered while calculating time difference:

  • The hour (HH) value must be in the range 0 through 23. If it falls outside the range, it will be defaulted to 0.
  • The minute (mm) value must be in the range 0 through 59. If it falls outside the range, it will be defaulted to 0.
  • The second (ss) value must be in the range 0 through 59. If it falls outside the range, it will be defaulted to 0.
  • If the time difference is more than a day, it is converted into elapsed number of hours. For instance, a time difference of 1 day and 10 hours would be treated as 34 hours.

Examples

 start = "6-Jan-2020 10:10:12";
 end = '7-Jan-2020 11:20:12';
 difference = start.timeBetween(end); // difference is assigned the value '25:10:2'

Related Links

Get Started Now

Execute