DateTime and DateTimeOffset pitfalls in .NET when time zones and clock changes collide
A .NET backend developer describes how storing dates without their time zone led to inconsistent query results across regions in a production UI. The core problem was that SQL Server's datetime2 column dropped the offset from DateTimeOffset values, so the same filter returned different rows depending on the user's zone. The article explains that a day with a daylight saving transition lasts 25 or 23 hours, so fixed 24-hour calculations can miss data. It also contrasts DateTime's ambiguous Kind handling with DateTimeOffset, which preserves a moment in time but not the originating time zone. The author proposes keeping the zone alongside the instant and sets out criteria for a solution that avoids building a custom time zone database.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in