date_sub function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns the date numDays before startDate.

Syntax

date_sub(startDate, numDays)

Arguments

  • startDate: A DATE expression.
  • numDays: An INTEGER expression.

Returns

A DATE.

If numDays is negative abs(num_days) are added to startDate.

If the result date overflows the date range the function raises an error.

Examples

> SELECT date_sub('2016-07-30', 1);
 2016-07-29