Hi! I have been a .NET developer since 2016, mostly on the backend. Most of my work is about data: moving it, storing it and reading it back. And then a date shows up.

The bug

We had a UI used by people from different time zones. One of its main features was filtering the data by date. The app had a DateTimeOffset, but the column in SQL Server was datetime2. SQL Server copies the date and the time and cuts the offset off, so 01:30+02:00 became just 01:30. Work for most of the time, to be fair. For simple CreatedAt columns

And on the day the clocks changed, everything blew up.

Take two users, one in Berlin and one in Tokyo, and the same filter: 25 October 2026. In Tokyo the day starts at 2026-10-24T15:00Z and lasts 24 hours. In Berlin the clocks go back that night from 03:00 to 02:00, so the day starts at 2026-10-24T22:00Z and lasts 25 hours. Two different ranges, and both of them are correct. A filter that counts every day as 24 hours cuts the last hour of the Berlin day.

Why DateTimeOffset is not enough

DateTimeOffset keeps the point in time, so two servers always agree. But it keeps an offset, not a zone. +02:00 is also Johannesburg, where nothing changes in October. So midnight +02:00 plus one day is 24 hours, and the day ends at 23:00 in Berlin.

You need the zone. NodaTime has it, and if you already use it, stay with it. I wanted something smaller: the BCL types, with the zone attached. So I wrote DateTimeZone, a struct with a DateTimeOffset and a TimeZoneInfo.

The filter

dotnet add package SolTechnology.DateTimeZone
using SolTechnology.Time;

var day = new DateOnly(2026, 10, 25);
var midnight = new TimeOnly(0, 0);
var tokyo = Zones.Resolve("Asia/Tokyo");

var from = new DateTimeZone(day, midnight, Zone.EuropeBerlin);
var to = from.AddDays(1);
var berlinDay = to - from;            // 1.01:00:00, 25 hours

var tokyoFrom = new DateTimeZone(day, midnight, tokyo);
var tokyoTo = tokyoFrom.AddDays(1);
var tokyoDay = tokyoTo - tokyoFrom;   // 1.00:00:00, 24 hours

var fromUtc = from.UtcDateTime;       // 2026-10-24T22:00:00Z
var toUtc = to.UtcDateTime;           // 2026-10-25T23:00:00Z

The query takes CreatedAt >= fromUtc AND CreatedAt < toUtc. The same code for both users, without a single if. The user's zone comes with the request, as text. The browser gives it with Intl.DateTimeFormat().resolvedOptions().timeZone.

As text the value is 2026-10-25T00:00:00+02:00[Europe/Berlin]. This format is RFC 9557, Java's ZonedDateTime writes the same, so the zone survives JSON too.

Limits

It is young, 2.0 is from October 2026. And zones come from the operating system: chiseled and distroless .NET images, and Alpine without tzdata, have no zones at all.

Summary

Our bug was not the filter. It was the database column that kept the date and the time and dropped the rest. Whatever type you pick, keep the zone next to the moment.

The longer version, with DateTime, DateTimeOffset and DateTimeZone compared on the day the clocks change, is here: https://dev.to/adrianstrugala/one-day-25-hours-datetime-datetimeoffset-and-time-zones-in-net-31b7