Common Date Reports (MTD, WoW, YoY)
Build month-to-date, week-over-week, and year-over-year reports with date_trunc and self-joins or window functions.
Three Classic Period Reports
Almost every business dashboard needs:
- MTD — Month-to-Date
- WoW — Week-over-Week
- YoY — Year-over-Year
Month-to-Date
Sum of this month so far:
SELECT SUM(total) AS mtd_revenue
FROM orders
WHERE created_at >= date_trunc('month', NOW())
AND created_at < date_trunc('month', NOW()) + INTERVAL '1 month';All lessons in this course
- Date Arithmetic and INTERVAL
- EXTRACT, DATE_TRUNC, AGE
- Time Zones: TIMESTAMP vs TIMESTAMPTZ
- Common Date Reports (MTD, WoW, YoY)