SQL Extract Month
Returns the month as a number from 1 to 12 — no month names, just the numeric position in the year.
What & Why
EXTRACT(MONTH FROM date_column) returns 1 through 12. Like quarter, month numbering resets every year, so pairing with EXTRACT(YEAR FROM ...) matters whenever data spans more than one year.
See How It Works
BUSINESS QUESTION
Growth wants signup counts by calendar month number.
| 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
EXTRACT(MONTH FROM created_at)::int AS signup_month,
COUNT(*) AS signups
FROM growth.users
GROUP BY signup_month
ORDER BY signup_month;RESULT — exact output from the displayed Queryflo rows
| signup_month | signups |
|---|---|
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
The four user signups occupy four distinct calendar months.
Now You Try
Practice this concept
Growth wants signup counts by calendar month number.
Available schema
growthPrefix tables with growth.table_name.
signup_monthsignupsgrowth.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