between

between(startDateInclusive: Date, endDateExclusive: Date): Period

Returns a Period (P) value consisting of the number of years, months, and days between two Date values.

The start date is included, but the end date is not. The result of this method can be a negative period if the end date (endDateExclusive) is before the start date (startDateInclusive).

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

startDateInclusive

The start date, inclusive.

endDateExclusive

The end date, exclusive.

Example

This example shows how between behaves with different inputs.

Source

import * from dw::core::Periods
output application/json
---
{
   a: between(|2010-12-12|,|2010-12-10|),
   b: between(|2010-11-10|,|2011-12-11|),
   c: between(|2020-02-29|,|2020-03-30|)
}

Output

{
   "a": "P2D",
   "b": "P-1Y-1M-1D",
   "c": "P-1M-1D"
 }

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub