Date subtraction calculates an earlier date by subtracting a specified interval from an existing date. SQL syntax depends on the database platform.
Subtracting intervals is useful for finding previous periods, historical reporting windows, expiration dates, and prior business events.
An analyst may need all transactions from the previous 30 days relative to the current date.
SELECT
CURRENT_DATE - INTERVAL '30' DAY AS PreviousDate;
Date subtraction is useful for rolling reports, customer activity analysis, compliance reviews, financial reporting, and monitoring.
- Date subtraction calculates an earlier date.
- Intervals can represent days, months, or other units.
- Syntax varies between SQL systems.
- It is useful for historical periods.
- It supports rolling-window analysis.
What is date subtraction?
Date subtraction calculates an earlier date by subtracting a specified interval from a date.
Why is date subtraction useful?
It helps create historical reporting windows and calculate previous dates or periods.