Home > Blockchain >  Should historical SQL UTC Dates change when currently viewing in DST
Should historical SQL UTC Dates change when currently viewing in DST

Time:10-04

Let's say I have a date stored in UTC time in SQL using the datetime type. In C#, I am converting to the client using .ToLocalTime().

Will the time value itself be different depending on when I look at it? That is, during DST or not?

For example, the actual hour of this historic event (2022-09-30T16:00:00.00) is stored 4 hours ahead, so it converts as 12pm. This is correct. But when DST ends, and it's 5 hours ahead, will it show as being done at 11am? Is there a method to always show the actual hour it happened in the past, not adjusted?

CodePudding user response:

No, because September 30 is always with DST. It doesn't matter if you check it in May or January, dates in September have always DST.

You can trivially try it out yourself: Create a new DateTime object for 2022-02-03 (no DST) and output it now. Currently, we observe DST, but the date in February will still be output without DST, because DST is not applied in February.

  • Related