SQL • LESSON 34
DATE_ADD & DATE_SUB
Learn how to add or subtract time intervals from SQL dates.
🟠 Intermediate⏱ 3 Minutes⭐ 530 XP
🤔 THE QUESTION
How can we find the date 30 days after an employee's joining date?
💡 WHAT IS IT?
DATE_ADD adds a specified time interval to a date, while DATE_SUB subtracts an interval from a date.
🎯 WHAT IS IT USED FOR?
These functions are useful for calculating deadlines, subscription periods, expiry dates, future dates, historical windows, and other date-based business rules.
💻 EXAMPLE
SELECT
name,
DATE_ADD(join_date, INTERVAL 30 DAY)
AS review_date
FROM employees;Mission Brief
Practice adding and subtracting date intervals to calculate future and past dates.
Objectives
- ✓ DATE_ADD
- ✓ DATE_SUB
- ✓ INTERVAL
- ✓ DAY
- ✓ Date calculations