Codú
Aileen Smith4 min read

Three meanings of ‘last 7 days’, with one tiny event log

A dashboard says Last 7 days. One reader expects the previous 168 hours. Another expects seven completed calendar dates. A third expects today and the six dates before it.

Those choices produce different results even when the filter code follows its specification perfectly. A small event log makes the difference visible.

Fix the clock before discussing the result

This is a fictional fixture, with one event per row. We are counting events, not people or accounts.

The reference instant is 2026-11-10T12:00:00Z. Every timestamp and calendar boundary in this exercise uses UTC.

Each interval includes its start and excludes its end:

start <= occurred_at < end

For the two windows that end at the reference instant, an event exactly at noon belongs outside this snapshot.

ID  occurred_at
A   2026-11-02T23:59:59Z
B   2026-11-03T00:30:00Z
C   2026-11-03T06:00:00Z
D   2026-11-03T12:00:00Z
E   2026-11-04T00:00:00Z
F   2026-11-09T23:59:59Z
G   2026-11-10T09:00:00Z
H   2026-11-10T12:00:00Z

Keeping this fixture in UTC isolates the choice of window. A localized product also needs to decide whose time zone defines a calendar date.

Meaning 1: the previous 168 hours

Start at noon on November 3 and stop just before noon on November 10.

start: 2026-11-03T12:00:00Z
end:   2026-11-10T12:00:00Z

included: D E F G
count:    4

Event D is exactly on the included lower boundary. Events B and C are too early. Event H is exactly on the excluded upper boundary.

This definition keeps the window's duration fixed as the reference clock moves.

Meaning 2: the previous seven complete UTC dates

Use November 3 through November 9. Today's partial date is outside the report.

start: 2026-11-03T00:00:00Z
end:   2026-11-10T00:00:00Z

included: B C D E F
count:    5

The early November 3 events now count. Event G does not: it happened on November 10.

A person looking for a report of completed dates could reasonably expect this result. The original label did not establish that expectation as the contract.

Meaning 3: today and the six preceding UTC dates, so far

Use the dates November 4 through November 10, with today's data ending at the reference instant.

start: 2026-11-04T00:00:00Z
end:   2026-11-10T12:00:00Z

included: E F G
count:    3

This covers seven named dates. The final date is incomplete, so it does not cover seven complete days.

Event E sits on this window's included start. Event G counts as part of today. Event H remains outside the snapshot.

Compare membership as well as the number

Here are the three expected results together:

Previous 168 hours       D E F G      4
Seven complete dates    B C D E F    5
Today plus six dates    E F G        3

All three use the same comparison rule. Their boundaries differ.

Keep the expected event IDs beside the count when reviewing an implementation. An unintended inclusion and an unintended exclusion can cancel each other out in the total. A matching number alone can hide the wrong membership.

The useful review questions are concrete: Does D enter the rolling window? Does G stay out of the completed-date report? Does H stay outside the exclusive end?

Put the decision into the interface

Choose wording that communicates the selected behavior. Last 168 hours, Previous 7 complete UTC days, and Today + previous 6 dates describe three different contracts.

A compact interface can explain the full definition in help text or a date-range summary. Shared reports and exports should carry the same definition so that opening another view does not silently change the question.

Two other choices deserve explicit treatment: whether the timestamp represents when an event occurred or when it was ingested, and whether the reference instant stays fixed when a report is shared. The fixture above makes neither choice for a real product.

This is a small example of owning a metric from problem to outcome. The person responsible for the number needs to settle its meaning, connect that decision to implementation examples, and check the resulting behavior.

For this filter, eight invented rows are enough to expose a decision that the label leaves open.

Product-engineering
Aileen Smith@aileensmith

Notes on software behavior, product decisions, and the handoff between them.

Discussion 0

Loading

Got something to say?

or to join the conversation.

Learn to build with AI and grow with people doing the same — it's free.