# DateDiff

The **DateDiff** function calculates the time difference between two dates.

### Syntax

`DateDiff(unit, start, end)`

The function has the following arguments:

|          |                                                                                                                                                                                                                                                                                   |
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **unit** | (required) The unit to measure the difference. Can be one of “year”, "quarter", “month”, “week”, “day”, “hour”, “minute”, “second”, “millisecond”.                                                                                                                                |
| start    | (required) The starting date. Note that the value must be a date. If the column is not in the appropriate format, use the [date](https://support.meetuma.ai/uma-knowledgebase/data-and-reporting/analytics-pro/functions/type-functions/date "mention") function on the argument. |
| **end**  | (required) The ending date. Note that the value must be a date. If the column is not in the appropriate format, use the [date](https://support.meetuma.ai/uma-knowledgebase/data-and-reporting/analytics-pro/functions/type-functions/date "mention") function on the argument.   |

### Examples

```
DateDiff(“day”, [Invoice Date], Today())
```

Returns the number of days between the date in the *Invoice Date* column and the current UTC date.

```
DateDiff("year", [Invoice Date], Date("2018-01-01")) = 8
```

Returns the number of years between the date in the *Invoice Date* column and January 1, 2018.

```
DateDiff("hour", [Ticket Date], Now()) = 103
```

Returns the number of hours between the date and time in the *Ticket Date* column and the current UTC date and time.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.meetuma.ai/uma-knowledgebase/data-and-reporting/analytics-pro/functions/date-functions/datediff.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
