One date rule
Keep the raw event timestamp as your source of truth. Create date, week, or month fields in the query when you need them.
Most wrong product numbers come from unclear time zones, half-open days, or grouping by the full timestamp instead of the date.
Know your columns
Product events usually have an event timestamp, like created_at or event_time. That is the exact moment an event happened.
For analytics, you often need a calendar day, week, or month. These are derived from the timestamp, not stored as a replacement.
Choose the grain
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done
Bad date filters
Do not filter a full day with event_time = '2026-01-10'. A timestamp includes hours, minutes, and seconds, so this will miss most rows.
Use a start time and an end time. The end should be exclusive. This avoids bugs at 23:59:59 and works cleanly for weeks and months too.
Daily signups
This query counts signups per day for January 2026. It keeps the filter on the timestamp, then groups by the date.
This style works in PostgreSQL. If your database has different date functions, keep the same idea.
SELECT
DATE(created_at) AS signup_date,
COUNT(*) AS signups
FROM users
WHERE created_at >= TIMESTAMP '2026-01-01'
AND created_at < TIMESTAMP '2026-02-01'
GROUP BY DATE(created_at)
ORDER BY signup_date;Handle India time
If your app stores UTC timestamps, decide whether the product question needs UTC or India time. A UPI payments dashboard for Indian users usually needs India time.
Write the choice in your project explanation. For example: “All daily metrics use Asia/Kolkata calendar days.”
Weekly orders
Weeks are useful when daily numbers are noisy. For hackathon projects, week-level charts are easier to explain than 30 small daily bars.
This query groups paid orders by week and checks revenue in rupees.
SELECT
DATE_TRUNC('week', paid_at) AS paid_week,
COUNT(*) AS paid_orders,
SUM(amount_rupees) AS revenue_rupees
FROM orders
WHERE paid_at >= TIMESTAMP '2026-01-01'
AND paid_at < TIMESTAMP '2026-04-01'
GROUP BY DATE_TRUNC('week', paid_at)
ORDER BY paid_week;Do this now
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done