---
title: Get Time Between Dates
description: Get the time between two dates
---

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

## What it does

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.

## When to use it

* 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.

## Inputs and settings

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

## Outputs

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.

## Dependencies and credentials

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

## Example workflow

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

1. [Format Date](/nodes/builtin/datatransformation/datetime/formatdate/), **Date to format** `{{ $input.dueDate }}`, **Format** `Unix MS Timestamp`, **Output field name** `dueMs`, **Include input fields** on.
2. [Get Current Date](/nodes/builtin/datatransformation/datetime/getcurrentdate/) then another Format Date with `Unix MS Timestamp`, **Output field name** `nowMs`, both with **Include input fields** on.
3. [Math](/nodes/builtin/datatransformation/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](/nodes/builtin/flow/if/) that both are `0` to know two dates are in the same month.

## Common issues

* **"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`.

## Related nodes

* [Extract Part Of A Date](/nodes/builtin/datatransformation/datetime/extractpartofadate/): read one part of a single date.
* [Format Date](/nodes/builtin/datatransformation/datetime/formatdate/): convert dates to timestamps for exact differences.
* [Math](/nodes/builtin/datatransformation/math/): subtract and divide timestamps.
* [IF](/nodes/builtin/flow/if/): branch on the result.