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
| Value | Type |
|---|---|
| 2024-01-15 | DATE |
| 2024-01-15 09:30:00 | TIMESTAMP |
| 2024-01-15 09:30:00+00 | TIMESTAMPTZ |
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
productPrefix tables with product.table_name.
feature_iduser_idused_atproduct.feature_usage| Column | Type |
|---|---|
| id | bigint |
| feature_id | integer |
| user_id | integer |
| used_at | timestamp with time zone |
| session_id | text |
| deprecated_usage_source | text |
query.sql
Sign up free to try it on a real business scenario