Skip to content
Agentic Workflowdocs
v0.8.2Install free

nodes / builtin / datatransformation / datetime

Get Time Between Dates

Get the time between two dates

Data ExtensionWeb app

Compare the parts of two dates, such as their years or their days of the month.

Get Time Between Dates reads Start date and End date and, for each unit you tick in Units, subtracts the start’s value for that part from the end’s value. The results go into one object under Output field name, with one key per unit.

Each unit compares only that part of the two dates, not the total time between them:

Unit What it subtracts
year The years.
month The months of the year (0 to 11).
week, day The days of the month (both give the same number).
hour, minute, second, millisecond That part of the clock time.

For example, from 2026-01-31 to 2026-03-02 gives { year: 0, month: 2, day: -29 }. The values are read in your computer’s local time zone.

  • Check whether two dates fall in the same year or month (the result is 0).
  • Compare clock times on the same day, such as how many hours separate two meetings today.

To get the total elapsed time (for example “how many days until the deadline”), use the recipe in the example below instead.

SettingTypeWhat it does
Start date (required)Date and timeThe start date.
End date (required)Date and timeThe end date.
Units (required)Multiple choiceThe units to express the difference in. Larger units are filled first; smaller ones get what remains. Options: year, month, week, day, hour, minute, second, millisecond.
Output field name (required)TextThe name of the output field.
Options GroupThe options for the node.
Options › Include input fields ToggleWhether to include the input fields in the output. Default: Off

Both dates accept a picked date or an expression such as {{ $input.dueDate }}. Tick at least one unit.

  • Output

The item holds an object under Output field name, for example { diff: { year: 1, month: -2 } }. Read one value downstream with {{ $input.diff.year }}. A negative number means the end’s part is smaller than the start’s.

None. This node needs no connection and has no slots for other nodes.

Count the whole days until a deadline (total elapsed time):

  1. Format Date, Date to format {{ $input.dueDate }}, Format Unix MS Timestamp, Output field name dueMs, Include input fields on.
  2. Get Current Date then another Format Date with Unix MS Timestamp, Output field name nowMs, both with Include input fields on.
  3. Math, Operation Subtract, Value {{ $input.dueMs }}, Second Value {{ $input.nowMs }}, Put Result In Field msLeft.
  4. Math, Operation Divide, Value {{ $input.msLeft }}, Second Value 86400000 (one day in milliseconds), Put Result In Field daysLeft. Add a third Math with Operation Round down if you want whole days.

Use Get Time Between Dates itself for same-period checks: Units year and month, then an IF that both are 0 to know two dates are in the same month.

  • “day” is negative although the end date is later. The node subtracts days of the month, not total days. From the 31st to the 2nd of a later month gives a negative number. Use the recipe above for elapsed time.
  • “week” shows the same number as “day”. Both compare the day of the month. It is not a count of weeks.
  • “Invalid duration unit”. A unit in Units is not one of the listed values. Re-select the units from the list.
  • The values are NaN. One of the dates could not be read. Use ISO dates such as 2026-03-05.
Edit page

Last updated:

Was this page useful?
Ask Aria about Get Time Between Dates