# DATE\_SUB

## Syntax

```sql
DATE_SUB(date,INTERVAL expr unit)
```

## Description

Performs date arithmetic. The *date* argument specifies the starting date or datetime value. *expr* is an expression specifying the interval value to be subtracted from the starting date. *expr* is a string; it may start with a "`-`" for negative intervals. *unit* is a keyword indicating the units in which the expression should be interpreted. See [Date and Time Units](https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date-and-time-units) for a complete list of permitted units.

See also [DATE\_ADD()](https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date_add).

## Examples

```sql
SELECT DATE_SUB('1998-01-02', INTERVAL 31 DAY);
+-----------------------------------------+
| DATE_SUB('1998-01-02', INTERVAL 31 DAY) |
+-----------------------------------------+
| 1997-12-02                              |
+-----------------------------------------+
```

```sql
SELECT DATE_SUB('2005-01-01 00:00:00', INTERVAL '1 1:1:1' DAY_SECOND);
+----------------------------------------------------------------+
| DATE_SUB('2005-01-01 00:00:00', INTERVAL '1 1:1:1' DAY_SECOND) |
+----------------------------------------------------------------+
| 2004-12-30 22:58:59                                            |
+----------------------------------------------------------------+
```

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}
