Basics

Get the Current Date & Time in SQL (per Dialect)

2 min read

The current date and timestamp — the building block for “today”, “now”, and date math.

-- MySQL
SELECT CURRENT_DATE, NOW();            -- date, datetime

-- PostgreSQL
SELECT CURRENT_DATE, NOW();            -- date, timestamptz

-- BigQuery
SELECT CURRENT_DATE(), CURRENT_TIMESTAMP();

-- Snowflake
SELECT CURRENT_DATE, CURRENT_TIMESTAMP();

-- SQLite
SELECT DATE('now'), DATETIME('now');   -- text, UTC

-- DuckDB
SELECT CURRENT_DATE, NOW();

Just the time, or the year

-- current time only
SELECT CURRENT_TIME;                    -- MySQL / Postgres / DuckDB
SELECT CURRENT_TIME();                  -- BigQuery
SELECT TIME('now');                     -- SQLite

-- current year
SELECT EXTRACT(YEAR FROM CURRENT_DATE); -- Postgres / DuckDB / Snowflake / BigQuery
SELECT YEAR(CURRENT_DATE);              -- MySQL / Snowflake
SELECT strftime('%Y', 'now');           -- SQLite

Gotchas: SQLite’s 'now' is UTC — add the 'localtime' modifier (DATETIME('now', 'localtime')) for local time. In Postgres, NOW() and CURRENT_TIMESTAMP return timestamptz (zone-aware); LOCALTIMESTAMP drops the zone. BigQuery CURRENT_TIMESTAMP() is UTC-based; use CURRENT_DATETIME('America/New_York') for a wall-clock value in a zone.

Open the full version (with copy buttons) ↗

← All recipes