between(endDateExclusive: Date, startDateInclusive: 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).

Note that the first parameter of the function is the endDateExclusive and the second one is the startDateInclusive.

Introduced in DataWeave version 2.3.0.


Name Description


The end date, exclusive.


The start date, inclusive.


This example shows how between behaves with different inputs.


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


   "a": "P2D",
   "b": "P1Y1M1D",
   "c": "P-1M-1D"

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub
Submit your feedback!
Share your thoughts to help us build the best documentation experience for you!
Take our latest survey!