Date labeled wrong with Arcade

5465
11
Jump to solution
11-14-2019 11:41 AM
JeffThomasILM
Occasional Contributor II

I keep losing a day when labeling with Arcade. I have a date field (not text) with manually entered dates, e.g., "5/1/2003". I did not enter any times. If I label it with Python by simply calling the date field, [Date], it returns exactly that date and formatting. If I call the field with Arcade, $feature.Date, it labels as: "2003-04-30T20:00:00-04:00". I figured out how to format the date: Text($feature.Date,'M/D/Y')‍, and though it's kind of annoying that that's necessary when using Arcade, I at least get it. But the head-scratcher is why I've lost a day. Note that the labeled date is 2003-04-30 (or 4/30/2003), not 5/1/2003 as it should be. I'm sure it has something to do with the time shift. But the question is, how do I prevent this from happening? Do I have to reformat my data? Seems silly that I should have to do that, but at least I'd know what to do. Or is there a way to leave the data as it is and use Arcade to re-format properly? Thanks!

11 Replies
JeremyDavies
New Contributor III

Doh! Of course that's shorter and cleaner, and works perfectly. I tried something like that initially and must have had the syntax wrong because it failed, so I assumed you had to pull out YYYY, MM, and DD separately. Thanks for the suggestion!

bsanders69
Occasional Contributor

One thing to note as well...  If you only put in a Date, the timestamp is set 00:00:00 UTC.  Everytime zone West of Longitude 0 degrees will subtract an hour for each time zone, so the American continents will subtract time from midnight, making the day one day earlier.  I feel that ESRI should make strides to eliminate this throughout their products, since they recommend that you use UTC as your database time zone.