Industrial IoT
Which shift owns a carton scanned at exactly 2 pm?
Give adjacent reporting periods a shared boundary and include it on one side only. Four scans show how an inclusive end can double-count production.
Choose one ownership rule for the boundary between shifts. A common choice is the half-open interval: include the start and exclude the end. Then a carton stamped exactly 14:00 belongs to the shift beginning at 14:00. Adjacent shifts partition the day without requiring anyone to guess the last representable millisecond of the previous shift.
Test the changeover with four cartons
Suppose unique scans occur at 13:59:59, 14:00:00, 14:00:00 and 14:00:01. The two scans at exactly 14:00 belong to different cartons. With the half-open rule, the morning shift counts one and the afternoon counts three. If both shifts use inclusive start and end tests, the morning counts three and the afternoon counts three. Four physical cartons have become six reported scans.

Worked data
Reporting approach | Morning + afternoon | Combined cartons |
Actual unique cartons | 1 + 2 + 1 by second | 4 |
Both ends inclusive | 3 + 3 by shift | 6 |
Start inclusive only | 1 + 3 by shift | 4 |
Download the figures in this worked example (CSV)
Do not solve the wrong duplication problem
Dropping repeated timestamps would remove one genuine carton at 14:00. Use event or carton identity to reconcile retransmissions; use the interval rule to allocate events in time. Preserve the source clock’s precision and convert to a declared reporting time zone before deriving shift boundaries.
PostgreSQL documents inclusive and exclusive bounds for ranges. The convention can be implemented in other databases and spreadsheets as well. A practical acceptance test compares the sum of consecutive shift counts with the distinct events for the combined period, including overnight shifts and records added late. Recalculate late events under the same boundary rule and keep the revision visible to the supervisor.
How to handle a late-arriving carton
Suppose a fifth carton was scanned at 13:59:58 but a mobile terminal synchronises it at 14:07. Allocation by scan time adds one to the morning shift. Allocation by receipt time adds one to the afternoon shift. The interval convention does not resolve this choice because two different event times are involved. Decide which timestamp measures production and retain the other to explain data arrival.
Publish the reporting cut-off alongside the shift totals. A supervisor may need a prompt provisional figure, while a downstream reconciliation can wait for terminals to reconnect. If a late record changes a closed shift from one carton to two, preserve the time of the revision and the unique identifier that caused it. Silently replacing yesterday’s figure forces the next analyst to guess which figure the production meeting actually saw.
The same method handles shifts that cross midnight. Construct the start and end for the real local schedule, convert those boundaries to instants and apply the half-open test. This avoids assuming every calendar day has exactly 24 local clock hours and avoids assigning a scan to a date merely because its UTC date label rolled over.
Sources
PostgreSQL · Range types and inclusive or exclusive bounds
Cover illustration by Industry Applied, generated with AI. Two shift handover records at a factory desk.
Related reading
Choose one ownership rule for the boundary between shifts. A common choice is the half-open interval: include the start and exclude the end. Then a carton stamped exactly 14:00 belongs to the shift beginning at 14:00. Adjacent shifts partition the day without requiring anyone to guess the last representable millisecond of the previous shift.
Test the changeover with four cartons
Suppose unique scans occur at 13:59:59, 14:00:00, 14:00:00 and 14:00:01. The two scans at exactly 14:00 belong to different cartons. With the half-open rule, the morning shift counts one and the afternoon counts three. If both shifts use inclusive start and end tests, the morning counts three and the afternoon counts three. Four physical cartons have become six reported scans.

Worked data
Reporting approach | Morning + afternoon | Combined cartons |
Actual unique cartons | 1 + 2 + 1 by second | 4 |
Both ends inclusive | 3 + 3 by shift | 6 |
Start inclusive only | 1 + 3 by shift | 4 |
Download the figures in this worked example (CSV)
Do not solve the wrong duplication problem
Dropping repeated timestamps would remove one genuine carton at 14:00. Use event or carton identity to reconcile retransmissions; use the interval rule to allocate events in time. Preserve the source clock’s precision and convert to a declared reporting time zone before deriving shift boundaries.
PostgreSQL documents inclusive and exclusive bounds for ranges. The convention can be implemented in other databases and spreadsheets as well. A practical acceptance test compares the sum of consecutive shift counts with the distinct events for the combined period, including overnight shifts and records added late. Recalculate late events under the same boundary rule and keep the revision visible to the supervisor.
How to handle a late-arriving carton
Suppose a fifth carton was scanned at 13:59:58 but a mobile terminal synchronises it at 14:07. Allocation by scan time adds one to the morning shift. Allocation by receipt time adds one to the afternoon shift. The interval convention does not resolve this choice because two different event times are involved. Decide which timestamp measures production and retain the other to explain data arrival.
Publish the reporting cut-off alongside the shift totals. A supervisor may need a prompt provisional figure, while a downstream reconciliation can wait for terminals to reconnect. If a late record changes a closed shift from one carton to two, preserve the time of the revision and the unique identifier that caused it. Silently replacing yesterday’s figure forces the next analyst to guess which figure the production meeting actually saw.
The same method handles shifts that cross midnight. Construct the start and end for the real local schedule, convert those boundaries to instants and apply the half-open test. This avoids assuming every calendar day has exactly 24 local clock hours and avoids assigning a scan to a date merely because its UTC date label rolled over.
Sources
PostgreSQL · Range types and inclusive or exclusive bounds
Cover illustration by Industry Applied, generated with AI. Two shift handover records at a factory desk.

