---
title: DATE_DIFF
url: https://www.tines.com/docs/formulas/functions/date-diff/
kind: formula-function
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/docs/llms.txt) › [Formulas](https://www.tines.com/llm/docs/formulas.md) › [Functions](https://www.tines.com/llm/docs/formulas/functions.md)*

# DATE_DIFF

*[View on tines.com](https://www.tines.com/docs/formulas/functions/date-diff/)*

Returns the precise difference between two given times in terms of years, months, weeks, days, hours, minutes, and seconds. It handles differences across time zones, accounts for leap years, considers months with varying days, and presents both the unit and cumulative differences. When the start time is after the end time the result is returned with absolute values unless the parameter 'absolute' with a value of FALSE is passed in.

**Categories:** Dates/Times

## Syntax

```
DATE_DIFF(start_time, end_time, [absolute: TRUE])
```

## Examples

### Example 1

Formula:

```
DATE_DIFF('2023-11-03T10:00:00-05:00', '2023-11-03T13:30:45-04:00')
```

Output:

```json
{
  "seconds": 9045,
  "minutes": 150.75,
  "hours": 2.51,
  "days": 0.1,
  "weeks": 0.01,
  "units": {
    "years": 0,
    "months": 0,
    "weeks": 0,
    "days": 0,
    "hours": 2,
    "minutes": 30,
    "seconds": 45
  }
}
```

### Example 2: absolute is TRUE by default, so values are positive when the start time is after the end time

Formula:

```
DATE_DIFF('2023-03-02T11:09:01+0000', '1992-12-18T15:11:01+0000')
```

Output:

```json
{
  "seconds": 953063880,
  "minutes": 15884398,
  "hours": 264739.97,
  "days": 11030.83,
  "weeks": 1575.83,
  "units": {
    "years": 30,
    "months": 2,
    "weeks": 1,
    "days": 4,
    "hours": 19,
    "minutes": 58,
    "seconds": 0
  }
}
```

### Example 3

Formula:

```
DATE_DIFF('2023-03-02T11:09:01+0000', '1992-12-18T15:11:01+0000', absolute: FALSE)
```

Output:

```json
{
  "seconds": -953063880,
  "minutes": -15884398,
  "hours": -264739.97,
  "days": -11030.83,
  "weeks": -1575.83,
  "units": {
    "years": -30,
    "months": -2,
    "weeks": -1,
    "days": -4,
    "hours": -19,
    "minutes": -58,
    "seconds": 0
  }
}
```

## Sample actions

```json
{
  "standardLibVersion": "38",
  "actionRuntimeVersion": "4",
  "agents": [
    {
      "disabled": false,
      "name": "DATE_DIFF",
      "description": null,
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "different_time_zones": "=DATE_DIFF('2023-11-03T10:00:00-05:00', '2023-11-03T13:30:45-04:00')",
          "longer_duration": "=DATE_DIFF('1992-12-18T15:11:01+0000', '2023-03-02T11:09:01+0000')"
        }
      },
      "position": {
        "x": -495,
        "y": 675
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "recordType": null,
      "recordWriters": [],
      "form": null,
      "cardIconName": null,
      "createdFromTemplateGuid": null,
      "createdFromTemplateVersion": null,
      "originStoryIdentifier": "cloud:da01f7810b72a1e6a5f2ecffe9db1bf1:0aa471f556d31ea505d131f9bca3d099"
    }
  ],
  "links": [],
  "diagramNotes": []
}
```
