Skip to content

Date Math

Adds or subtracts calendar, elapsed, or business time from a date or datetime.

@lainstack/time/date-math · Data

Use this block to add or subtract an amount of time from a date or a date and time. For the current moment, use @lainstack/time/current first. To pause the run until a time, use @lainstack/time/wait. To compare two dates, use @lainstack/flow/condition with the date type.

  • inputKind date takes a value like 2026-03-31. Seconds, minutes and hours need datetime. With a date input, time, localIso, iso and epochMs are null.
  • amount is a whole number from 0 to 1,000,000. To go back in time set operation to subtract. Do not use a negative amount.
  • months and years keep the day if they can and otherwise use the last day of the month. 31 January plus 1 month is the last day of February.
  • On a date and time, days, weeks, months and years keep the local clock time. hours, minutes and seconds add exact elapsed time.
  • A date and time without an offset is read in timezone (default UTC). A local time that does not exist (clocks moved forward) fails. A time that exists twice uses disambiguation, earlier by default.
  • business_days skips weekendDays (default Saturday and Sunday) and the listed holidays (up to 64 dates, YYYY-MM-DD). Both lists are fixed in the block. The limit is 10,000 business days. Zero business days returns the same date, even on a weekend.
  • An invalid date, an unknown timezone or a result outside years 0001 to 9999 fails the step.
Setting Key Type Details
Input type (required) inputKind One of Date, Date and time Default date.
Value (required) value Date A literal or one whole-value reference.
Operation (required) operation One of Add, Subtract Default add.
Amount (required) amount Number
Unit (required) unit One of Seconds, Minutes, Hours, Days, Weeks, Months, Years, Business days Default days.
Timezone (required) timezone Text IANA timezone used to resolve and format the result.
Repeated local time disambiguation One of Earlier, Later Choose which instant to use when clocks move back. Default earlier.
Weekend days weekendDays List Days excluded by Business days arithmetic. At most 6 items.
Holidays holidays List Specific YYYY-MM-DD dates excluded by Business days arithmetic. At most 64 items.
Output Path Type
Input kind kind Text
Result result Text
Resolved timezone resolvedTimezone Text
Date date Date
Time time Text
Local ISO localIso Text
UTC ISO iso Text
Epoch milliseconds epochMs Number