> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# days_diff

> Returns the day difference between two date expressions (expr1 − expr2), accurate to the day.

Returns the day difference between two date expressions (`expr1` − `expr2`), accurate to the day.

Difference between days\_diff and [datediff](/documents/4.2/sql-reference/sql-functions/date-time-functions/datediff.md):

| Function | Behavior | Example |
| - | - | - |
| days\_diff | The calculation is accurate to the second and rounded down to the nearest integer. | days\_diff between '2020-12-25 23:00:00' and '2020-12-24 23:00:01' is 0. |
| datediff | The calculation is accurate to the day. | datediff between '2020-12-25 23:00:00' and '2020-12-24 23:00:01' is 1. |

## Syntax

```Haskell theme={null}
BIGINT days_diff(DATETIME expr1,DATETIME expr2);
```

## Parameters

* `expr1`: the end time. It must be of the DATETIME or DATE type.

* `expr2`: the start time. It must be of the DATETIME or DATE type.

## Return value

Returns a BIGINT value.

NULL is returned if the date does not exist, for example, 2022-02-29. days\_diff() takes the hour, minute, and second parts into calculation. If the difference is less than 1 day, 0 is returned.

## Examples

```Plain theme={null}
select days_diff('2010-11-30 23:00:00', '2010-11-29 23:00:00')
+---------------------------------------------------------+
| days_diff('2010-11-30 23:00:00', '2010-11-29 23:00:00') |
+---------------------------------------------------------+
| 1                                                       |
+---------------------------------------------------------+

select days_diff('2010-11-30 23:00:00', '2010-11-29 23:10:00')
+---------------------------------------------------------+
| days_diff('2010-11-30 23:00:00', '2010-11-29 23:10:00') |
+---------------------------------------------------------+
| 0                                                       |
+---------------------------------------------------------+
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.