All stories
Article

Define “today” before you build a business app report

Choose the date field, reporting time zone, and day boundaries so a business app’s daily list and exported report include the intended records.

By Noe Guerrero III

“Show today’s requests” sounds like a simple feature. Before building it, ask which date counts and whose day the report uses. A request created late at night can fall on different calendar dates in different time zones. Its requested service date may be something else entirely.

Write a short report rule before judging the total. Name the date field, reporting time zone, selected day, and what happens at its start and end. Then check identifiable records against that rule on the screen and in the export.

Choose the date that answers the question

Imagine a fictional McAllen equipment-repair business building an app for incoming requests. One record might contain the time it was received, the day the customer requested service, and the time staff last edited it.

Those fields answer different questions. “Requests received today” should use the agreed receipt timestamp. “Jobs requested for today” should use the requested service date. A staff edit shouldn’t quietly change which report the record belongs to unless the report is deliberately based on the last-edit time.

Give each report a clear name. If the team wants both views, build two named views with their own rules. A date picker labeled “Today” doesn’t resolve an ambiguous underlying question.

Also distinguish a calendar date from an event that happened at a specific moment. W3C’s draft guidance on time zones distinguishes plain date values from instants on a timeline. A date-only service day should keep its intended calendar meaning when someone opens the app from another time zone.

Ask the developer how that distinction is represented and validated. Don’t fix a date-only value by casually attaching midnight and letting another part of the app treat it as a moment to convert.

Name the reporting zone and define both boundaries

For this fictional business, the owner chooses America/Chicago as the reporting zone for received requests. That choice belongs in the specification. It shouldn’t silently follow the browser’s location or the server’s default setting.

The team can still display an individual timestamp in another zone when useful. Make that display choice clear. A customer-service employee traveling elsewhere should be able to understand why a request appears in the business’s daily report even when their local clock shows another date.

For a calendar-day report based on timestamps, my starting rule would be to include the start of the selected day and stop just before the start of the following day, both interpreted in the reporting zone. A record exactly at the following day’s start belongs to that following day.

That avoids guessing the last representable fraction of a second before midnight. It also gives adjacent reports a shared boundary without counting the same instant twice.

Have the developer calculate the next calendar-day boundary using time-zone-aware tools. Don’t assume every local reporting day is exactly 24 elapsed hours. PostgreSQL’s date/time documentation illustrates how adding one calendar day and adding 24 hours can produce different results across a daylight-saving transition. This principle matters even if your app uses a different database.

Test the edges with records you can identify

Agree on expected membership before running the report. Use designated test records with known values and stable IDs. For the repair business’s received-requests view, start with these cases:

  • A record received just before the selected day starts, which should be excluded.

  • A record received exactly at the start, which should be included.

  • A record received near the end of the selected day, which should be included.

  • A record received exactly at the following day’s start, which should be excluded.

  • A record received on a different day but requesting service on the selected day, which should follow the receipt rule in this view.

Check the separate service-date view against its own expected results. That last record may belong there. It isn’t an error for two deliberately different reports to contain different records.

Repeat the timestamp checks on a daylight-saving transition date where the chosen zone observes one. Include the relevant clock-change cases the developer identifies. A passing test on an ordinary date doesn’t establish that the boundary calculation handles those days.

Then open the same report from a browser set to a different time zone. Keep the selected business date and report rule unchanged. Inspect the record IDs, not just the count: two different mistakes can leave the total looking correct.

Carry the same rule into the export

The export should identify the report, selected dates, and reporting zone. If it lists event timestamps, make their zone or offset unambiguous. Someone reading the file later shouldn’t have to remember which browser produced it.

Compare the export with the report’s intended full result set, including rows beyond the first page. Use the same field, boundaries, permissions, and freshness basis. If records arrived between viewing and exporting, account for that difference rather than immediately blaming a time-zone bug.

Decide how a long-running export resolves “today.” A job that starts before midnight and finishes afterward needs an agreed reporting date and range, not an unexplained switch halfway through. Record the resolved range with the export job.

Imported timestamps and calendar dates need the same definitions. Our CSV import preview guide covers reviewing mappings and proposed changes before committing them; include date interpretation in that review when it affects report membership.

Hand over the report rule, test record IDs, expected inclusions and exclusions, and observed screen/export results. That gives the business and developer a concrete answer to a useful question: which records does this day actually include?