DATE_SUB function in BigQuery
The DATE_SUB function in BigQuery subtracts a specified time interval from a DATE value and returns the result in DATE data type.
SQL Syntax
DATE_SUB(date_expression, INTERVAL int64_expression date_part)
Supported date_part Values
- DAY
- WEEK – Equivalent to 7 DAYS
- MONTH
- QUARTER
- YEAR
Note: Special handling is required for MONTH, QUARTER, and YEAR when the date is at or near the last day of the month. If the resulting month has fewer days than the original date, the resulting date becomes the last day of that month.
Example: Subtract 5 days from a given date.
SQL
SELECT DATE_SUB(DATE(2026, 01, 10), INTERVAL 5 DAY) AS five_days_ago;
The output of the above query is shown below:
