Complete the code to add 7 days to the current date.
SELECT DATE_ADD(CURDATE(), INTERVAL [1] DAY);The DATE_ADD function adds a specified interval to a date. Here, adding 7 days to the current date.
Complete the code to subtract 3 months from the date '2024-06-15'.
SELECT DATE_SUB('2024-06-15', INTERVAL [1] MONTH);
The DATE_SUB function subtracts a specified interval from a date. Here, subtracting 3 months from June 15, 2024.
Fix the error in the code to add 10 hours to the current timestamp.
SELECT DATE_ADD(NOW(), INTERVAL [1] HOUR);The interval value must be a number without quotes, and the unit must be uppercase singular like HOUR.
Fill both blanks to subtract 15 days and add 2 weeks to '2024-01-01'.
SELECT DATE_ADD(DATE_SUB('2024-01-01', INTERVAL [1] DAY), INTERVAL [2] WEEK);
First subtract 15 days, then add 2 weeks to the date '2024-01-01'.
Fill all three blanks to add 1 year, subtract 6 months, and add 10 days to '2023-03-10'.
SELECT DATE_ADD(DATE_SUB(DATE_ADD('2023-03-10', INTERVAL [1] YEAR), INTERVAL [2] MONTH), INTERVAL [3] DAY);
The code adds 1 year, subtracts 6 months, then adds 10 days to the given date.