Hi all,
I was hoping someone could help me as I'm struggling to get dates to work in the web form. I have a survey that is pulling in data using the javascript functionality including some dates, which are coming into my form in epoch time format e.g. 1325635200000. After reviewing Ismael's blog post here and the help section on decimal date time I've attempted to convert my epoch date using the decimal-date-time function. My set up can be seen below N.B. I split up the calculations to see where the issue was occurring but originally just had one field with a single combined calculation.
In Survey123 Connect, this all works fine (see below) but in the web form I find that the decimal-date-time calculation simply won't fire (see second image below).
I've tried various combinations on this and none of them seem to work. I even went back and tried the example Ismael proposed in his blog post below and had no joy with this. Can someone please look at this and let me know if I'm doing anything wrong or is there currently a bug in the S123 web form that is preventing this from working? Any help on this would be very much appreciated. Thanks, Anthony
@IsmaelChivite @Anonymous User
Solved! Go to Solution.
I was able to get this to work by dividing the epoch timestamp by 86,400,000 (1000 * 60 * 60 * 24) and then using the date() function to convert to a date object. Let me know if that works for you!
-Andrew
Hi Anthony,
I am struggling with some thing very similar to your case. Have you menage to find a solution or a workaround? Did you get any feedback outside the esri community?
Thank you very much,
Dory
Hi Dory,
Unfortunately I never got a response on this and ended up removing the date element from my form. I can imagine there may be a way to convert the date in the javascript but I'm pretty much a novice with javascript so wouldn't know how. I suspect this issue may persist though when people are using the new pulldata from a feature service functionality as I'd assume any dates pulled into a json will also be in the UNIX epoch format although I haven't had chance to test it out yet.
Hi @IsmaelChivite @Anonymous User, sorry for tagging you both again but I was wondering if the issue described above is a recognised bug or are we doing something wrong? Any help would be much appreciated.
Kind Regards
Anthony
Hi Andrew,
Thank you so much for your response, I've managed to replicate that with my form. Just wish I'd thought of that 10 months ago!
I'll be bookmarking this page so I can remind myself the next time I forget how to do it!
Thanks again,
Anthony
@AndrewO_support I'm also struggling with the differences between the field app and web app.
I finally got my date calculation to work in the web app (where most of my users will be), but it is definitely handling something differently in the preview and field app. Makes testing... interesting!
I am pulling a birthday from another hosted feature layer in my survey - say May 15, 2022 at 12PM, or epoch time 1652630400000. If I try converting it to date, I get "December 31 1969 at 12 PM" in the field app or the correct time, May 15 2022 at 12 PM in the web app.
Attached my example here. Anyone know how I can get the two platforms to agree this is May 15, 2022?
I had help from Alex at ESRI Canada and finally resolved this. I want users to enter an animal ID and then have the survey pull the animal's birthday from another hosted feature class.
I had to force field types for some fields (decimal and dateTime), then ensure the fields were hidden and readonly = yes (I am going to use the dates in a calculation rather than show them, and this ensures they appear properly in the S123 webapp editor).
Cell that pulls date from hosted feature class is type decimal, and calculation is:
pulldata("@layer", "getValue", "attributes.animal_date_born", "replace_with_your_hosted_feature_layer_in_AGOL", concat('animal_id=', "'",${animal_id},"'"))
calculation cell to convert to dateTime is type dateTime and contains:
date-time(int(${animal_date_born}) div 86400000)
Screenshot:
example xlsx form is attached.
Thank you - great post, was stuck for half a day until I found your setup. Appreciate the screenshot and attachment.