---
title: diffDays()
slug: diffdays
createdAt: 2026-02-09T14:47:04.886Z
---

Returns the number of days between two dates. The result is positive when `date2` is after `date1`, and negative when `date2` is before `date1`.

### Syntax

`diffDays(date1, date2)`

### Parameters

| **Parameter** | **Type**                                   | **Description**                     |
| ------------- | ------------------------------------------ | ----------------------------------- |
| `date1`       | **[Date](https://docs.charthop.com/date)** | The date from which counting begins |
| `date2`       | **[Date](https://docs.charthop.com/date)** | The date at which counting ends     |

### Return Type

**[Number](https://docs.charthop.com/ucI5-number)**

The number of days between the two dates.

### Examples

`diffDays('2025-01-01', '2025-12-31')`

- Returns `364`.

`diffDays('2025-03-15', '2025-01-01')`

- Returns `-73` because `date2` is before `date1`.

### Related Carrot

- **[diffWeeks()](https://docs.charthop.com/diffweeks)** - Returns the number of whole weeks between two dates
- **[diffMonths()](https://docs.charthop.com/diffmonths)** - Returns the number of whole months between two dates
- **[diffYears()](https://docs.charthop.com/diffyears)** - Returns the number of whole years between two dates
