download

Why do billing and analytics disagree on daily revenue?

Data analytics~9 minReviewed 3 Dec 2026Free · No sign-in

Question

Finance reports daily revenue by New York business day (America/New_York), while your analytics table groups the same orders by UTC date. Look at five orders around Sunday, 8 March 2026 (when New York springs forward from EST -05:00 to EDT -04:00 at 07:00 UTC):

OrderUTC timestampNew York local timeAmount
ord_12026-03-08T02:30:00Z2026-03-07 21:30 EST$300
ord_22026-03-08T04:15:00Z2026-03-07 23:15 EST$200
ord_32026-03-08T15:00:00Z2026-03-08 11:00 EDT$400
ord_42026-03-09T01:30:00Z2026-03-08 21:30 EDT$600
ord_52026-03-09T03:45:00Z2026-03-08 23:45 EDT$500
  1. What is March 8 revenue under UTC versus New York, and why do they differ by $600?
  2. How do spring-forward (23h) and fall-back (25h) DST days distort hourly and daily metrics?
  3. How should you store and query timestamps so both teams agree?
Show hints (3)
  1. "CHECK TOTAL REVENUE"

    Sum all five orders first ($2,000). Both pipelines see the same $2,000, so the $600 gap is purely a date-boundary shift.

  2. "COUNT DST HOURS"

    New York's 8 March 2026 skips 02:00 to 02:59 (23 hours total). Its 1 November 2026 repeats 01:00 to 01:59 (25 hours total).

  3. "STORE UTC CONVERT LATE"

    Persist every event as a UTC instant (TIMESTAMPTZ or RFC 3339 Z), then convert at query time with an IANA zone name like America/New_York.

Show checked explanation

March 8 revenue is $900 in UTC (ord_1 to ord_3) versus $1,500 in New York (ord_3 to ord_5), a $600 shift even though both sum to $2,000. Store every timestamp as a UTC instant and convert at query time using an IANA zone name (America/New_York), never a fixed offset. Normalize DST days by 23 or 25 elapsed hours.

"SOLUTION · PYTHON"
from datetime import datetime, timedelta, timezone

EST, EDT = timezone(timedelta(hours=-5)), timezone(timedelta(hours=-4))
DST_START = datetime(2026, 3, 8, 7, 0, tzinfo=timezone.utc)
ORDERS = [
    ("2026-03-08T02:30:00Z", 300), ("2026-03-08T04:15:00Z", 200),
    ("2026-03-08T15:00:00Z", 400), ("2026-03-09T01:30:00Z", 600),
    ("2026-03-09T03:45:00Z", 500),
]
utc_day, ny_day = {}, {}
for ts, amt in ORDERS:
    dt = datetime.fromisoformat(ts)
    tz = EDT if dt >= DST_START else EST
    utc_d = dt.date().isoformat()
    ny_d = dt.astimezone(tz).date().isoformat()
    utc_day[utc_d] = utc_day.get(utc_d, 0) + amt
    ny_day[ny_d] = ny_day.get(ny_d, 0) + amt

print("UTC:", utc_day)
print("NY :", ny_day)
"OUTPUT"
UTC: {'2026-03-08': 900, '2026-03-09': 1100}
NY : {'2026-03-07': 500, '2026-03-08': 1500}

UTC vs New York daily buckets, DST day lengths (23h and 25h), and fixed-offset drift run on CPython 3.12.10 (Windows x64) against the sample orders above; official IANA, RFC 3339, PostgreSQL, and Python links checked. Checked by an editor other than the author.

Walkthrough

No orders disappeared. Across all five rows, both dashboards sum to $2,000. The $600 gap on March 8 happens because New York sits 4 to 5 hours behind UTC, so late-evening US orders land on the next UTC date:

  • ord_1 ($300) and ord_2 ($200) happen on March 7 evening in New York (21:30 and 23:15 EST), yet UTC puts $500 into March 8.
  • ord_4 ($600) and ord_5 ($500) happen on March 8 evening in New York (21:30 and 23:45 EDT), yet UTC pushes $1,100 into March 9.
  • Net shift on March 8: +$1,100 - $500 = +$600 ($1,500 New York vs $900 UTC).
Reporting dateUTC bucketNew York bucketDifference (NY - UTC)
2026-03-07$0$500+$500
2026-03-08$900$1,500+$600
2026-03-09$1,100$0-$1,100
Total$2,000$2,000$0

Why Daylight Saving Time (DST) makes daily and hourly charts lie:

  • Spring forward (2026-03-08): New York midnight (05:00 UTC) to next midnight (04:00 UTC) lasts only 23 hours. Local 02:00 to 02:59 never happens, creating a fake zero-traffic hour and a -4.2% (23/24 - 1) dip in daily totals.
  • Fall back (2026-11-01): Midnight (04:00 UTC) to next midnight (05:00 UTC) lasts 25 hours. Local 01:00 to 01:59 occurs twice (05:00 UTC in EDT and 06:00 UTC in EST). Grouping by naive local hour doubles the 01:00 bar and inflates daily totals by +4.2% (25/24 - 1).
  • Fixed-offset bug: Hardcoding -05:00 breaks as soon as EDT starts. An order at 2026-03-09T04:30:00Z is 00:30 EDT on March 9, yet -05:00 puts it at 23:30 on March 8 for the next eight months.

The reliable warehouse pattern:

"SQL"
SELECT (created_at AT TIME ZONE 'America/New_York')::date AS ny_day,
       SUM(amount_usd) AS revenue_usd
FROM orders
GROUP BY 1
ORDER BY 1;

Store every event timestamp as an unambiguous UTC instant (TIMESTAMPTZ in PostgreSQL, RFC 3339 Z in logs). Convert at query time with a full IANA zone name (America/New_York in SQL or Python's ZoneInfo with tzdata), never a fixed offset or local server time.

Common mistakes

  • Subtracting a fixed 5 hours (INTERVAL '5 hours') for Eastern Time. Every order between 00:00 and 00:59 EDT lands on the wrong business day from March through October.
  • Storing naive local timestamps without an offset or zone. During the fall-back hour (01:00 to 01:59), two real hours collapse into one ambiguous wall-clock time.
  • Relying on the database session's default time zone. A BI tool connecting from UTC and a finance job running in America/New_York silently produce different dates from the same query.
  • Comparing raw 23-hour or 25-hour DST days against normal 24-hour days without normalizing by elapsed hours (-4.2% and +4.2% swings look like real business shocks).

Follow-up questions

  • "Should global metrics like DAU use UTC or each user's local time zone?" Use one canonical reporting zone (usually UTC or company headquarters time) for financial totals and company-wide dashboards so daily sums match exactly. Use the user's local zone only for local-habit features like daily streaks or morning notifications.
  • "How do you avoid a broken chart during the 25-hour fall-back day?" Bucket hourly series by UTC instant (date_trunc('hour', created_at) in UTC) and format the axis labels with the offset (01:00 EDT, 01:00 EST). For daily KPI alerts, monitor rate per hour or 7-day rolling totals.
  • "Why are abbreviations like EST or CST unsafe in SQL or Python configs?" Abbreviations are ambiguous (CST means US Central, China, or Cuba) and do not switch automatically on DST dates. Always pass full IANA names such as America/New_York or Europe/London.

What a strong answer covers

Reconciles the $600 March 8 gap ($900 UTC vs $1,500 NY) while confirming total revenue is $2,000. Explains 23-hour, 25-hour, and fixed-offset DST traps, and prescribes UTC storage with explicit IANA query-time conversion.

Open in interactive practice deck →

Original OfferVibe question. IANA Time Zone Database · RFC 3339 Timestamps · PostgreSQL Date/Time Functions · Python zoneinfo.
© 2026 OfferVibe · Text CC BY-NC-SA 4.0 · code MITFree to share and adapt with credit, not for commercial use. Code samples are free for any use.