Learn SQL/Beginner/Data Types & Casting/SQL TIMESTAMP Data Type

SQL TIMESTAMP Data Type

A date AND a time together — down to fractional seconds, optionally aware of timezone.

What & Why

TIMESTAMP stores both a calendar date and a time of day. Postgres offers two variants: TIMESTAMP (no timezone awareness — stores exactly the value given) and TIMESTAMPTZ (timezone-aware — stored internally in UTC, converted for display based on the session's timezone setting).

See How It Works

REFERENCE EXAMPLE
ValueType
2024-01-15DATE
2024-01-15 09:30:00TIMESTAMP
2024-01-15 09:30:00+00TIMESTAMPTZ

The result uses the same Queryflo columns shown in the worked example.

Now You Try

Practice this concept

Product wants the 25 most recent feature-use events with their feature, user, and exact event timestamp.

Available schema
product

Prefix tables with product.table_name.

feature_iduser_idused_at
product.feature_usage
ColumnType
idbigint
feature_idinteger
user_idinteger
used_attimestamp with time zone
session_idtext
deprecated_usage_sourcetext
query.sql
Beginner business practice

Sign up free to try it on a real business scenario