0Pricing
SQL Academy · Lesson

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

  1. Date Arithmetic and INTERVAL
  2. EXTRACT, DATE_TRUNC, AGE
  3. Time Zones: TIMESTAMP vs TIMESTAMPTZ
  4. Common Date Reports (MTD, WoW, YoY)
← Back to SQL Academy