---
title: DATEDIFF
description: Learn how to use the DATEDIFF function to calculate the difference between two dates in days, months, years, and more.
---
import { Aside, Steps } from '@astrojs/starlight/components';

# DATEDIFF

The DATEDIFF function in Infoveave calculates the difference between two dates in terms of a specified interval, such as days, weeks, months, quarters, years, hours, minutes or seconds.

## Applicable to

Calculated Columns

## Return Value

DATEDIFF function returns an integer value representing the difference between the start and end dates in terms of the specified interval.

## Remark

* The interval parameter specifies the unit of time you want to use for the calculation. For example, if you use DAY, the function will calculate the difference in terms of days.
* If start is later than end, the function will return an error.
* If either start or end date is NULL, the function will return an error.
* If interval is not one of the valid options (DAY, WEEK, MONTH, QUARTER, YEAR, HOUR, MINUTE, SECOND), the function will return an error.

## Syntax

```
DATEDIFF(start, end, interval)
```

<Aside type="tip">
You can call in the system defined date function start date and end date as `@StartDate` and `@StartDate` respectively.
</Aside>


## DATEDIFF in Calculated Columns



| Parameter | Description |
|---|---|
| Start | The start date of the period you want to calculate the difference from. |
| End | The end date of the period you want to calculate the difference to. |
| Interval | The interval you want to use for the calculation. This can be days, weeks, months, quarters, years, hours, minutes or seconds. |


Steps to Use DATEDIFF

<Steps>
1. Write the DATEDIFF function. For instance ```DATEDIFF(start, end, interval)```
2. Replace `start` with the start period. You can also call in `@StartDate` function.
3. Replace `end` with the end period. You can also call in `@EndDate` function.
4. Replace `interval` with the interval value required.
5. To learn how to add calculated columns in Infoveave, visit the section [Calculated Columns](/studio-v8/datasources/calculated-columns-datasource/).
</Steps>


## Example 1

Suppose you want to calculate the month difference between two dates, you can use the DATEDIFF function as follows

```
DATEDIFF(DATE(2024, 10, 01), DATE(2024, 12, 01),MONTH)
```

The calculated column will return the value 2.

## Example 2

Suppose you want to use the system defined start and end date, you can use the DATEDIFF function as follows

```
DATEDIFF(@StartDate, @EndDate, DAY)
```

The calculated column will return the value, based on the month.

