Learn SQL/Intermediate/Date & Time/SQL Add Days to a Date

SQL Add Days to a Date

The simplest date arithmetic — a plain + sign between a date and a number.

What & Why

date_column + n adds n days to a date. This is the pattern the Date Arithmetic lesson introduced, applied to a concrete, common use case: computing a follow-up date, a deadline, or an expiration.

See How It Works

BUSINESS QUESTION

Marketing wants a seven-day follow-up date for every lead.

idcampaign_idemailcreated_atqualified_atconverted_atlead_scoresourcecountry
3011ana@example.com2024-01-21 09:10:00+002024-01-22 11:00:00+002024-02-02 10:00:00+0086google_adsUS
3021ben@example.com2024-01-24 12:40:00+00NULLNULL52google_adsCA
3032chloe@example.com2024-02-16 08:30:00+002024-02-18 14:20:00+00NULL74emailGB
3043dev@example.com2024-03-20 17:15:00+002024-03-21 09:00:00+002024-04-04 16:00:00+0091linkedinUS
EXAMPLE QUERY
SELECT
  id AS lead_id,
  created_at,
  created_at + INTERVAL '7 days' AS follow_up_at
FROM marketing.leads
ORDER BY lead_id;
RESULT — exact output from the displayed Queryflo rows
lead_idcreated_atfollow_up_at
3012024-01-21 09:10:00+002024-01-28 09:10:00+00
3022024-01-24 12:40:00+002024-01-31 12:40:00+00
3032024-02-16 08:30:00+002024-02-23 08:30:00+00
3042024-03-20 17:15:00+002024-03-27 17:15:00+00

Each follow-up timestamp is exactly seven days after lead creation.

Now You Try

Practice this concept

Marketing wants a seven-day follow-up date for every lead.

Available schema
marketing

Prefix tables with marketing.table_name.

lead_idcreated_atfollow_up_at
marketing.leads
ColumnType
idinteger
campaign_idinteger
emailtext
created_attimestamp with time zone
qualified_attimestamp with time zone
converted_attimestamp with time zone
lead_scoreinteger
sourcetext
countrytext
archive_statustext
query.sql
Intermediate business practice

Sign up free to try it on a real business scenario