Skip to content

DATE_SUB

  • date: This parameter specifies the date from which the interval needs to be subtracted. It must be a valid date value that MySQL supports, including date expressions that return a date or datetime value.
  • interval expr type: The INTERVAL keyword and its following expression (expr) mean to subtract a certain time interval from the date we have in the first parameter. It has two parts
SELECT DATE_SUB('2008-01-02', INTERVAL 31 DAY);
'2007-12-02'

The above example demonstrates the usage of DATE_SUB function in MySQL. It subtracts a time interval from the provided date. In this case the interval is 31 days, subtracted from ‘2008-01-02’, which results in ‘2007-12-02’.