# DATE_DIFF

Calculates the number of days between two compatibility mode dates.

> [!IMPORTANT]
> **Important:** This function supports only compatibility mode dates. We recommend upgrading any older date fields in your data sources to the new Date or Date \& Time types and using the [DATETIME_DIFF](https://docs.cloud.google.com/data-studio/datetimediff) function instead. [Learn more](https://docs.cloud.google.com/data-studio/dates-and-times).

## Sample usage

`DATE_DIFF(End Date, Start Date)`

## Syntax

`DATE_DIFF( X, Y )`

### Parameters

- `X` - a date field or date expression.
- `Y` - a date field or date expression.

## Notes

`DATE_DIFF` calculates `X` - `Y`. If `X` \> `Y`, the result is positive, otherwise the result is negative.

## Examples

| Example formula | Input | Output |
|---|---|---|
| ` DATE_DIFF(End Date, Start Date) ` | - **End Date** : Sep 28 2019 - **Start Date** : Sep 10 2019 | 18 |
| ` DATE_DIFF(End Date, Start Date) ` | - **End Date** : Sep 9 2019 - **Start Date** : Sep 10 2019 | -1 |

## Related resources

- [Dates and times](https://docs.cloud.google.com/data-studio/dates-and-times)
- [Calculated fields](https://docs.cloud.google.com/data-studio/about-calculated-fields)
- [Data Studio function list](https://docs.cloud.google.com/data-studio/function-list)