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

  1. INSERT or SELECT runs
  2. Server reads its clock (date + time)
  3. Column has DEFAULT CURRENT_TIMESTAMP? Yes: Filled automatically on INSERT. No: Used only where written.
  4. Store or return the full timestamp
  5. Rows carry an exact, server-side time

Syntax

CURRENT_TIMESTAMP

Example

SELECT CURRENT_TIMESTAMP;

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