SQL TO_TIMESTAMP
TO_DATE's counterpart for timestamps — parses text into a full date-and-time value using an explicit format.
What & Why
TO_TIMESTAMP(text, format) works exactly like TO_DATE, but produces a full TIMESTAMP — parsing time-of-day components (hours, minutes, seconds) in addition to the date.
See How It Works
BUSINESS QUESTION
Growth checks that a user's stored signup moment survives an epoch round trip.
| id | created_at | country | channel | plan | activated_at | churned_at |
|---|---|---|---|---|---|---|
| 101 | 2024-01-15 09:10:00+00 | US | organic | pro | 2024-01-16 14:25:00+00 | NULL |
| 102 | 2024-02-10 11:05:00+00 | CA | paid | free | NULL | 2024-03-20 10:00:00+00 |
| 103 | 2024-03-12 16:35:00+00 | GB | referral | pro | 2024-03-13 08:15:00+00 | NULL |
| 104 | 2024-04-01 13:20:00+00 | US | organic | free | 2024-04-03 12:00:00+00 | NULL |
EXAMPLE QUERY
SELECT
id AS user_id,
EXTRACT(EPOCH FROM created_at) AS epoch_seconds,
TO_TIMESTAMP(EXTRACT(EPOCH FROM created_at)) AS parsed_created_at
FROM growth.users
ORDER BY user_id;RESULT — exact output from the displayed Queryflo rows
| user_id | epoch_seconds | parsed_created_at |
|---|---|---|
| 101 | 1705309800.000000 | 2024-01-15 09:10:00+00 |
| 102 | 1707563100.000000 | 2024-02-10 11:05:00+00 |
| 103 | 1710261300.000000 | 2024-03-12 16:35:00+00 |
| 104 | 1711977600.000000 | 2024-04-01 13:20:00+00 |
The epoch round trip reproduces every displayed signup moment.
Now You Try
Practice this concept
Growth wants signup epoch seconds converted back into typed timestamps.
Available schema
growthPrefix tables with growth.table_name.
user_idepoch_secondsparsed_created_atgrowth.users| Column | Type |
|---|---|
| id | integer |
| created_at | timestamp with time zone |
| country | text |
| channel | text |
| plan | text |
| activated_at | timestamp with time zone |
| churned_at | timestamp with time zone |
| legacy_user_code | text |
query.sql
Sign up free to try it on a real business scenario