Home / SQL / Reference / Dates

SQL date() and strftime()

Work with dates in SQLite.

Syntax

date('now')
date(d, '+30 days')
strftime('%Y-%m', d)

SQLite stores dates as ISO text ('2025-06-14'). date() calculates new dates, strftime() extracts parts: %Y year, %m month, %d day, %w weekday (0 = Sunday).

Example

Query (on the shop database used in the SQL course)

SELECT order_date,
       strftime('%Y-%m', order_date) AS month,
       strftime('%w', order_date) AS weekday,
       date(order_date, '+14 days') AS due
FROM orders
LIMIT 4;

Result

order_datemonthweekdaydue
2025-06-102025-0622025-06-24
2025-05-172025-0562025-05-31
2025-03-252025-0322025-04-08
2025-10-262025-1002025-11-09

4 rows

Good to know. PostgreSQL: CURRENT_DATE, d + INTERVAL '14 days', EXTRACT(MONTH FROM d), to_char(d, 'YYYY-MM').

Related

Learn it step by step in the free lesson Functions: Text, Numbers, Dates & CASE, with exercises that check your queries.