> For the complete documentation index, see [llms.txt](https://community-test.logicnets.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/date-difference.md).

# Date Difference

## Description

When using this part, the system returns the difference between two date-time variables, in a group (user-defined) that holds the difference in terms of seconds, minutes, hours, days, months and years.

## Use

This part allows users to assess how much time has passed between two events, or between a previous/future date and today (using now() as one of the date inputs). The output collection contains the difference in values in various time units of measure, as well as a flag to show whether the difference is positive or negative (whether the second input date is after or before the first).

## Editor Fields

| Field Name | Description/Use                                                                                                                                                                 | Type/Options      | Optional/Mandatory |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ------------------ |
| Group      | This field contains the group name within which the system stores the results.                                                                                                  | Container Name    | Mandatory          |
| Input type | This field allows the user to specify whether the date inputs are standard (YYMMDD.HHMMSS) or Epoch dates.                                                                      | Standard \| Epoch | Mandatory          |
| Date 1     | <p>This is the data object used as the start date in the calculation of difference.<br>If left blank this date will default to the exact date/time assessed during runtime.</p> | Data Object\*     | Optional\*\*       |
| Date 2     | <p>This is the data object used as the end date in the calculation of difference.<br>If left blank this date will default to the exact date/time assessed during runtime.</p>   | Data Object\*     | Optional\*\*       |
| Mode       | This is the "resolution" of the calculation and can be set to date or date and time.                                                                                            | date \| datetime  | Mandatory          |

**Part Editor Notes:**

\* Date inputs require the user to enter the $() data object construction.

\*\* If left blank the input is assumed to be now (current date and time), assessed at runtime (ie not the date the logic was modelled)

## Mode

Choosing the mode **calculate date difference** will ignore any timestamps included in the dates, and the output will not include hours or minutes except totals.

## Output

The date difference is output as objects in a group using the following naming conventions

* years, months, days, hours, minutes, seconds all calculate the **time-unit-specific** **whole number** **difference** of between that time unit in each date e.g.

  the **hours** difference of January 1st 9pm and January 3rd 9am is 12; the **days** difference is 1 (1 day to Jan 2nd pm, then a partial day to Jan 3rd am)
* total\_years, total\_months, total\_days, and total\_hours all calculate the **total number** of time units between the dates.

  The **total\_hours** difference of January 1st 9pm and January 3rd 9am is 36 (24 + 12). The total\_days difference is 1 (only 1 whole day between the dates).
* counted\_years, counted\_months, and counted\_days all calculate the total number of time units between the dates, but the system rounds them up in cases of fractional periods.

  The counted hours difference is 36 (no rounding required). The counted\_days difference is 2 (the 1st to the 3rd is 2 days, rounding up for the partial day).

![](https://2802811211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdFhfexCjZ5JMhwGzzywq%2Fuploads%2Fgit-blob-c488b7e3448992305a6ee7b188aa739ac977c358%2F0c0fe168-961a-462e-9f84-01261a35312c.jpg?alt=media)

* negative is set to 0 when the second input date is LATER than the first. In the event Date2 is EARLIER than Date1, negative is set to 1.

## Example

Using input dates of July 1st 2016 and April 28 2017 and defining the group as "diff" gives the following results in the context. Calculations are done for total difference and unit difference for seconds, minutes, hours, days, months and years.

![](https://2802811211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdFhfexCjZ5JMhwGzzywq%2Fuploads%2Fgit-blob-152bb8dd8c2b276366c82916d9ed739995a792be%2Fb3fdb905-53c0-48a6-9db4-0439a54b3702.jpg?alt=media)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/date-difference.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
