Hi Bart, If you store a date in an Object as a string, 4D interprets that date as a UTF date.
So “2019-02-24” (giving only the date but not time) is interpreted as midnight on the 24th. That is at the stroke of midnight when the 24th day **starts**. When you retrieve the value around 6:30 PST on the 24th, 4D is converting to your local time — which is several hours **before** the 24th begins. Hence you see the 23rd. If you pass a 4D date, the problem won’t happen. That is replace the string ("2019-02-24”) with a 4D date (#2019-02-24#). There’s also a compatibility setting that where you can specify that string dates are to be treated as 4D dates. That is, no time associated with the date. Then your expression: > OB SET($obj;"apiDate";"2019-02-24") would always return the 24th Best regards, Jeremy > On Feb 24, 2019, at 9:24 PM, Bart Davis via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > If you store a 4D date value in an object and retrieve it the value is > correct. However, if you retrieve a date that is stored in the format > YYYY-MM-DD, the date returned is one day less that the date stored. > > The code below illustrates the issue. I have only tested this on Mac OS > using 4D v17.1 (Note: I tested this at 6:30 pm PST and am not sure if GMT > offset has any effect) > > Has anyone else experienced this issue? > > Thanks, > Bart > > C_DATE($4dDate;$apiDate) > C_OBJECT($obj) > > $obj:=New object > $today:=Current date > > OB SET($obj;"4Ddate";$today) > OB SET($obj;"apiDate";"2019-02-24") > > $4dDate:=ob get($obj;"4Ddate";Is date) // date returned is correct 2019-02-24 > $apiDate:=ob get($obj;"apiDate";Is date) // ERROR: date returned is 2019-02-23 ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************