Storing an Instant or a Local Calendar Date

A timestamp used for ordering observations and a date used for a local policy encode different information. Column choice should match that intent.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace an opening deadline
  2. Test near midnight
  3. Use two records that differ after a time-zone conversion
  4. Decide which time zone a grouped report uses

Trace an opening deadline

A registration policy may close at a local date and time under a named time zone. An audit event instead records when an action occurred. Timestamps and durations explain why such fields need distinct interpretation.

Test near midnight

One instant can correspond to different local dates. Test a conversion near that boundary instead of selecting a convenient midday value. See date conditions.[1][2]

Use two records that differ after a time-zone conversion

An event at 23:30 UTC on June 3 can fall on June 4 in a zone at UTC+02:00 for that event. A local calendar date such as a promised delivery day can be meaningful without a particular instant. Store the kind of information the domain describes. See timestamps and durations.

Instant: June 3 at 23:30 UTC
Corresponding time with +02:00: June 4 at 01:30
Stored local appointment date could independently be June 3

Decide which time zone a grouped report uses

A midnight boundary varies by zone. Use explicit conversions before taking the date and test records on each side. For scheduled local times, handle ambiguous or skipped wall times according to policy.

References

  1. PostgreSQL Global Development Group, Data Definition ↩
  2. PostgreSQL Global Development Group, SQL Language Tutorial ↩