Skip to content

SUBDATE

  • date: This parameter is the starting date or datetime value. It represents where the operation begins. Date or datetime expressions can be used or literal string providing a valid date or datetime format.
  • interval expr unit: This is a combination of two sub-parameters, expr and unit. Expr represents the interval you want to subtract and unit is the type of interval being subtracted e.g., day, hour, month, year, etc. The interval value is an integer, and the unit can be in days, hours, minutes, seconds, months, or years.
SELECT SUBDATE('2022-01-01', INTERVAL 3 DAY);
'2021-12-29'

The SUBDATE function subtracts a specified time interval from a date. In the provided example, 3 days are subtracted from ‘2022-01-01’, resulting in the output ‘2021-12-29’.