CURRENT_TIMESTAMP
SQL · Date Functions
Theory
CURRENT_TIMESTAMP returns the current date and time together, such as 2026-11-08 14:30:05, often with fractions of a second. It is part of the SQL standard and works in almost every database, including SQL Server, which makes it the most portable way to ask 'what time is it now?'.
Its most common job is as a column default: created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP stamps each new row automatically, so the application never has to send the time. A detail that surprises beginners: in PostgreSQL the value is fixed at the start of the transaction, so every row inserted in one transaction gets the same timestamp (clock_timestamp() gives the real moving time). SQLite returns UTC text 'YYYY-MM-DD HH:MM:SS'. Whether the value carries a time zone depends on the dialect and column type, so decide on one convention, often storing UTC, and convert for display.
Why we use it
Audit trails, event logs and 'last updated' columns need an exact moment, not just a date. CURRENT_TIMESTAMP captures it on the server, so every row is stamped by the same clock instead of trusting many client machines.
When to use it
Use it for created_at/updated_at defaults, event logging and measuring durations. Use CURRENT_DATE when only the day matters (it makes grouping and comparisons simpler). Prefer storing UTC and converting to local time when displaying.
How it works
- INSERT or SELECT runs
- Server reads its clock (date + time)
- Column has DEFAULT CURRENT_TIMESTAMP? Yes: Filled automatically on INSERT. No: Used only where written.
- Store or return the full timestamp
- Rows carry an exact, server-side time
Syntax
CURRENT_TIMESTAMPExample
SELECT CURRENT_TIMESTAMP;Key points
- Most commonly used default value for audit columns
- Equivalent to NOW() in MySQL/Postgres
- Standard SQL — works in SQL Server, Oracle, Snowflake and SQLite too
- PostgreSQL fixes it at transaction start; use clock_timestamp() for the real moving time
- Pick one time zone convention (often UTC) for stored timestamps