0
  • summary:

I am trying summaries the issue, Issue is SQL server Table had an "invalid" time stamp in them. It was considered invalid after the date/time did not exist when the clocks moved 1 hour ahead at 2:00am. The entry that caused the issue time stamps of 02:58am on 03/13/2016. When the time change occurred and the clocks moved forward, these times are essentially in the past now which caused the issue.

  • Question:

issue occurred on 03/13/2016 but reported after long time, I want reproduce this again in my local env ? I db i am using string field for datetime and in C#.Net DateTime object.

I gone through so many blogs i think we know the solution but how can we ensure that every thing is working with reproduce this issue ..

Check if daylight savings is in effect? .net adds one hour to summer dst

Community
  • 1
  • 1
  • 1
    *Instead* of DateTime, use DateTimeOffset and avoid any assumptions about offsets. Just like codepages, there's no way to guarantee that you'll get everything right if 2 offsets are involved (3 if you count UTC, the only kind of DateTime you can depend on) – Panagiotis Kanavos Apr 15 '16 at 15:01
  • Thanks Panagiotis Kanavos, I agreed and this is the perfect solution to use DateTimeOffset but this problem occurs during DST only my Que is how can i reproduce it. even i tried in code and i put break point at int a then i moved time 1 hour ahead of my system even after that its not throughing error it is giving wrong value but not error as "invalid date" static void Main(string[] args) { DateTime s1 = DateTime.Now; int a = 1/2;//just break point DateTime s2 = DateTime.Now; TimeSpan e = s1 - s2; Console.Write(e); Console.ReadLine(); } – Anshuman Singh Apr 15 '16 at 20:08

0 Answers0