Date errors when assigning date.day > 28 in debug mode and Mac compiled apps

Hello

I’ve found today that if assigni .day .month and .year to a Date instance returns a wrong day if date.day > 28 (Web App. compiled for Linux Works fine).

If i do (This is on 2013r4.1 on a Mac Running 10.9.1)

Dim TheDate as new Date

TheDate.Day=31
TheDate.Month=1
TheDate.Year=2014

TheDate.SQLDate returns “2014-01-03”

If you do the same with TheDate.Day=30, then TheDate.SQLDate returns “2014-01-02”
For TheDate.Day=29, then TheDate.SQLDate returns “2014-01-01”

And finally for TheDate.Day<=28, then TheDate.SQLDate returns the correct date.

As i told i detected this debugging a Web App on Mac, the compiled version for Linux works fine.

Tried the same with a desktop app and the same happens. The compiled desktop (Mac) app ALSO FAILS!.

Is this some known? I’ve been unable to find something about this in feedback.

Best.

It’s one of those peculiarities with Dates. TheDate starts as today 03/02/2014. Setting the day to 31 makes this 3/3/2014, setting the month makes this 3/1/2014. Just always set the Year then Month then Day & you’ll be fine.

Just another topic which shows up every year in February :wink:

This is one of those glitches that seems to come and go. The Date is supposed to be like Schroedinger’s Cat, where it doesn’t resolve until you look at it. In other words, the order you set the values isn’t supposed to matter. But it does. Sometimes.

But why not code it

dim TheDate as new Date(2014, 1, 31)

Thank you, that worked. But i don’t understand why it worked right in the Linux compiled app and failed in the MacOSX one.

I just checked, and it works correctly on Windows, too, so it sounds like a Mac bug.

The docs state that with an empty constructor you’ll get back today’s date:

A quick test on Mac OS X, Windows, and Web (on Mac OS X and Windows) gives back the identical date January 3, 2014. Can’t test Linux though.

Windows 7, Xojo 2013r4.1, I consistently get the correct date, January 31, 2014, with this code:

  dim d as date
  d = new date
  d.day = 31
  d.month = 1
  d.year = 2014
  msgbox d.LongDate

why not use the constructor for passing date valueS?

dim d as new date(2014, 1, 31)