Categories: Date/Time

DATE_SUB

Subtracts the number of days from the specified date or timestamp.

Syntax

DATE_SUB(date_timestamp_expression DATE OR TIMESTAMP, days INTEGER) → DATE

  • date_timestamp_expression: The date or timestamp to subtract days from. This value must be a literal in the date or timestamp format.
  • days: Number of days to subtract from date_expression

Examples

SELECT DATE_SUB('2021-06-05', 5)
-- 2021-05-31
SELECT DATE_SUB('2021-06-24 06:11:51.567', 4)
-- 2021-06-20
SELECT DATE_SUB('2021-05-28', 10)
-- 2021-05-18