days(nDays: Number): Period

Creates a Period value from the provided number of days.

The function applies the period function to input that is a whole number and the duration function to decimal input.

Introduced in DataWeave version 2.4.0.


Name Description


The number of hours as a whole or decimal number. A positive or negative number is valid.


This example shows how days behaves with different inputs. It adds and subtracts hours from DateTime values. It also converts the decimal value 4.555 into a number of hours, minutes, and second in the Period format (PT109H19M12S) and the whole number 4 into a number of days in the Period format (P4D).


%dw 2.0
import * from dw::core::Periods
output application/json
   tomorrow: |2020-10-05T20:22:34.385Z| + days(1),
   yesterday: |2020-10-05T20:22:34.385Z| - days(1),
   decimalDaysPlusQuarter:  |2020-10-05T00:00:00.000Z| + days(0.25),
   decimalDaysPlusHalf:  |2020-10-05T00:00:00.000Z| + days(0.5),
   decimalDaysPlusThreeQuarters:  |2020-10-05T00:00:00.000Z| + days(0.75),
   decimalInputAsPeriod : days(4.555),
   fourDayPeriod: days(4),
   negativeValue: days(-1)


   "tomorrow": "2020-10-06T20:22:34.385Z",
   "yesterday": "2020-10-04T20:22:34.385Z",
   "decimalDaysPlusQuarter": "2020-10-05T06:00:00Z",
   "decimalDaysPlusHalf": "2020-10-05T12:00:00Z",
   "decimalDaysPlusThreeQuarters": "2020-10-05T18:00:00Z",
   "decimalInputAsPeriod": "PT109H19M12S",
   "fourDayPeriod": "P4D",
   "negativeValue": "P-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!