Results 1 to 10 of 11

Thread: Datetime bug found with DateAddDays

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009

    Angry Datetime bug found with DateAddDays

    This has been reported on elsewhere, but I can't find anything that says it's logged as a bug:

    If you do this:

    Datetime dt
    Get DateTimeSet 1899 12 30 0 0 0 0 to dt
    showln (DateAddDay(dt, 61))
    You'll get back 1900-02-29 12:00:00 am which is incorrect as 1900 was not a leap year. If you do this in C# in comparison:

    new DateTime(1899, 12, 30).AddDays(61)
    You'll get back 1900-03-01 12:00:00 AM which is correct. These datetime bugs are just killing me today! If this hasn't been properly recorded as a bug yet I'll submit it.

    Edit: I forgot to mention the other kicker here. Timespan does the math correctly. So if you take that 1899-12-30 date (which btw is the zero date for OADates) and subtract it from today you get the right number of days, but if you add that number of days to that 1899-12-30 you don't get back today, you get back yesterday because of that "fictional" 1900-02-29 leap day.

    Last edited by flxkid; 24-Aug-2021 at 08:39 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts