The function DAYS takes either two DateTimes or two Dates, and returns the number of days between them.

This function takes two pieces of input: either two Dates or two DateTimes. It outputs a Number: the number of days between the two DateTimes.

Declaration

DAYS(datetime1, datetime2) -> days
DAYS(date1, date2) -> days

 

Parameters

datetime1 (type: DateTime)
Any DateTime.
datetime2 (type: DateTime)
Any DateTime.
date1 (type: Date)
Any Date.
date2 (type: Date)
Any Date.

Return Values

days (type: Number)
The number of days between two dates.

Examples

Assume the first two examples have access to the following DateTime values:

example_date_and_time1 = {
"date": {
"day": 1,
"month": 4,
"year": 2021
},
"time": {
"hour": 16,
"minute": 14,
"second": 38,
"millisecond": 0
},
"timeZone": "UTC"
}

example_date_and_time2 = {
"date": {
"day": 16,
"month": 5,
"year": 2021
},
"time": {
"hour": 12,
"minute": 46,
"second": 12,
"millisecond": 4
},
"timeZone": "UTC"
}

The following example outputs the number of days between example_date_and_time1 and example_date_and_time2:

DAYS(example_date_and_time1, example_date_and_time2) = 44

The DAYS function returns the absolutely number of days between the two given dates; it doesn't matter what order they are given. The following example outputs the number of days between example_date_and_time2 and example_date_and_time1; note that this output is exactly the same as in the above example.

DAYS(example_date_and_time2, example_date_and_time1) = 44

The previous examples showcased how the DAYS function behaves when given DateTimes as input. To demonstrate how it behaves when given Dates, assume the last example has access to the following Date values:

example_date1 = {
"day": 1,
"month": 4,
"year": 2021
}

example_date2 = {
"day": 16,
"month": 5,
"year": 2021
}

The following outputs the number of days between example_date1 and example_date2. Note that the dates described by these Dates is the same as the dates described by the DateTimes given above, and so the output is exactly the same:

DAYS(example_date1, example_date2) = 44

 

Was this article helpful?

0 out of 0 found this helpful