I'm using a data expression for a pie chart in my dashboard. I could not get the date selector to work to set an filter action, and realized it's because it's seeing my date/time field (created_date) as a string.
I found this post from 2018 from @XanderBakker , listing out every month, etc to parse it out. Is this still necessary or is there a less involved way to get the data part into a date format. I don't need time, just M/D/Y.
what does the current string format look like?
Is the data being updated regularly or can you just do a field calculate on the original data, i.e. select the necessary year, month, day parts from the string and then form a Date object from that?
return Date(year, month, day)
if your data keep changing, you're going to have some fun doing this on the data expression side of things, basically taking the featureSet apart then rebuilding it with a new date field. but we can help you with that i'm sure, although i would say Xander is the guy to go to with these.
This is the format: 5/17/2021 10:44 AM
New records are being added daily, but once they are added, the date does not change. So it sounds like from your reply then, there is a simpler way than breaking it all part. I'm newer to Arcade but I'll look at your comment and see if I can figure it out.
I don't think so, featureSetByPortalItem() won't respect any on-the-fly arcade expressions you have in something like a web map. I think unless you alter your source data format to a datetime (and alter the current process to ensure you create one) you will have to rebuild from a feature dictionary.
here's a few examples:
I'm using the standard editor tracking date field in my hosted layer, so I don't think I have any options on altering the field type. I'm also a little confused on how it's technically a date field, but yet stored as string??
FYI, I went back to this and someone else had the same problem and a response had the fix. I had to cast my date field as a number, don't know why, but was an easy fix.
The post that had the fix is here: