Example 1 : Subtract 20 days to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL 20 DAY) as date;
// output : 2022-04-25 09:25:18
Example 2 : Subtract 11 months to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL 11 MONTH) as date;
// output : 2021-06-15 09:25:18
Example 3 : Add 2 months to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL -2 MONTH) as date;
// output : 2022-07-15 09:25:18
Example 4 : Add 1 year to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL 1 YEAR) as date;
// output : 2021-05-15 09:25:18
Example 5 : Subtract 12 weeks to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL 12 WEEK) as date;
// output : 2022-02-20 09:25:18
Example 6 : Subtract 12 hours to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL 12 HOUR) as date;
// output : 2022-05-14 21:25:18
Example 7 : Add 2 hours to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL -2 HOUR) as date;
// output : 2022-05-15 11:25:18
Example 8 : Subtract 12 minutes to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL 12 MINUTE) as date;
// output : 2022-05-15 09:13:18
Example 9 : Add 5 minutes to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL -5 MINUTE) as date;
// output : 2022-05-15 09:30:18
Example 10 : Subtract 12 seconds to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL 12 SECOND) as date;
// output : 2022-05-15 09:25:06
Example 11 : Subtract 7 days & seconds to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL '7 1:03:12' DAY_SECOND) as date;
// output : 2022-05-08 08:22:06
Example 12 : Subtract 7 days & minutes to a date and return the date:
mysql> SELECT DATE_SUB("2022-05-15 09:25:18", INTERVAL '7 1:03' DAY_MINUTE) as date;
// output : 2022-05-08 08:22:18