DATE_ADD()

SQL · Date Functions

Theory

DATE_ADD moves a date forward by a given interval and returns the new date. DATE_ADD('2026-11-05', INTERVAL 30 DAY) gives 2026-12-05. The interval can be days, weeks, months, years, or hours and minutes on timestamps, and the database handles month lengths and leap years for you.

The spelling depends heavily on the database. MySQL and BigQuery use DATE_ADD(date, INTERVAL 30 DAY). SQL Server and Snowflake use DATEADD(day, 30, date), with the unit first. PostgreSQL simply writes date + INTERVAL '30 days'. Oracle adds a number of days with date + 30 and months with ADD_MONTHS. SQLite uses date(order_date, '+30 days'). Adding months has an edge case: 31 January plus one month is 28 February in MySQL, but SQLite rolls over to 3 March, so always test month-end dates in your own database.

Why we use it

Business rules are full of 'X days later': due dates, delivery estimates, trial expiry, warranty end. DATE_ADD does calendar-aware arithmetic, so you never have to count days in a month or worry about leap years yourself.

When to use it

Use it to compute future dates (due date, expiry) or to build a window end. Adding a negative number moves backwards, but DATE_SUB or minus INTERVAL is clearer to read. To get the gap between two dates, use DATEDIFF instead.

How it works

  1. Start with a date, e.g. order_date
  2. Choose amount and unit: 30 DAY, 1 MONTH, 2 YEAR
  3. Database adds it on the calendar
  4. Past the end of the month? Yes: Apply the month-end rule (clamp or roll over). No: Keep the date.
  5. Return the new, later date

Syntax

DATE_ADD(date, INTERVAL n unit)

Example

SELECT DATE_ADD(hire_date, INTERVAL 30 DAY) FROM employees;

Key points

SQL topics

Introduction to SQL

Querying Data

Sorting Rows

Limiting Rows

Filtering Rows

Joining Multiple Tables

Grouping Rows

SET Operators

Working with Tables

Modifying Data

Views & Triggers

Conditional Expressions

SQL Subqueries

Aggregate Functions

Window Functions

String Functions

Date Functions

Math Functions

Extra Concepts

T
Tech Town
Log InSign Up Free
Home SQL Python DSA Power BI Snowflake Databricks Spark Gen AI Practice Problems Contest Blog

Master SQL from Zero to Pro

All SQL topics in one place. Click any topic in the sidebar — content opens right here without leaving the page.

{{ sectionCount }}
Sections
{{ topicCount }}
Topics
Free
Forever
Hands-on practice Practice SQL Online Solve 150 SQL interview problems in a live editor with instant checking. Start practising →
Section {{ sec.num }}

{{ sec.label }}

SQL  /  {{ current.sectionLabel }}  /  {{ current.name }}

{{ current.name }}

Theory

{{ current.def }}

Why we use it

{{ rich.why }}

When to use it

{{ rich.when }}

Diagram

{{ rich.dg.caption }}

{{ tb.title }}
{{ c.v }}
{{ rich.dg.op }}
➜
{{ rich.dg.output.title }}
{{ c.v }}
{{ nd.label }}
{{ nd.sub }}
{{ nd.label }}
{{ nd.sub }}
{{ rich.dg.left.title }}
{{ it }}
{{ rich.dg.right.title }}
{{ it }}
Flowchart — how it works
{{ nd.text }}
{{ nd.text }}
◇ {{ nd.text }}
Yes → {{ nd.yes }}
No → {{ nd.no }}
Syntax
{{ current.syntax }}
Example
{{ current.example }}
▶ Try It Live — runs against a real sample database
{{ liveError }}
{{ col }}
{{ cell }}
Key Points — click to check off as you learn
  • {{ pt.mark }} {{ pt.text }}

Share this topic