Date - SQLDate vs SQLDateTime

dim d as new date
d.SQLDate="2014-12-25 13:14:15"
msgbox d.shortdate+" "+d.shorttime

I would have expected the above to either give me “12/25/2014” or “12/25/2014 12:00:00” or produce an error
instead if gives me “12/25/2014 01:14:15 pm” {expected the TIME component to be ignored at best}

That is the result I would have expected if I used d.SQLDateTime

basically I can see no difference in how they react

The difference is in the output. Apparently, in the spirit of the the framework being helpful and just “doing the right thing”, it detects that there is a time portion and loads that as well. I think that is in fact the right thing for it to do.

That “kinda” makes sense… protect us from our own stupidtity I guess…

The reason this even came up was I was (off topic) duplicating the functionality of the XOJO date object in SWIFT (where it is not so forgiving)… so I just added a little nip/tuck and it now is as forgiving as this is :slight_smile:

Tested. My case it did not load the time, it ASSUMED the CURRENT computer time. I would expect 00:00:00 for the time part.

Found the behavior:

  //Dim d as new Date    //-- init with current time
  Dim d as new Date(0)   //-- Init with zero hour from 01/01/01
  d.SQLDate="2014-12-25 13:14:15" // Only sets the date part, keeps time
  msgbox d.shortdate+" "+d.shorttime // time is now zeroed