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

# DATE_SUB

> Subtracts a signed number of days from a date.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

Returns NULL if either argument is NULL. Date arithmetic overflow raises an error.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
date_sub(date, days)
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| date | DATE | Yes | Date from which days are subtracted. |
| days | INTEGER excluding BIGINT | Yes | Signed count of calendar days to subtract. |

## Returns

* Type: DATE
* NULL behavior: Returns NULL if either argument is NULL. Date arithmetic overflow raises an error.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Exact result | Yes |

## Units

* Input unit: Calendar days
* Output unit: DATE

## Usage notes

* A negative day count moves forward.

## Examples

### Subtract calendar days

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT date_sub(DATE '2024-01-15', 5) AS result;
```

| result |
| - |
| 2024-01-10 |

### A negative amount adds days

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT date_sub(DATE '2024-02-28', -2) AS later_date;
```

| later\_date |
| - |
| 2024-03-01 |

## Limitations

* BIGINT is not accepted for this SQL form. Use the integer types listed above; narrower integer conversions are not established here.
* Use DATE\_SUB; DATESUB is not an established SQL alias.


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