Select to view content in your preferred language

Formatting date in Survey123

33935
20
Jump to solution
10-05-2016 01:48 PM
bobwright
Frequent Contributor

Greetings. I've read Ismael's post regarding this, but it doesn't address the specific question I have. I understand that using the type "date" results in 10/5/16 12:00, but I would really like it to be 2016/10/05 12:00 so I can sort properly on them (10/21/16 sorts before 10/5/16 for example). The type "datetime" results in 16/5/10 which doesn't help much either. Changing the date format in the Regional settings of Windows does not help any. Suggestions? Thanks.

Tags (1)
1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

Hi Bob,

 the latest version of Survey123 for ArcGIS now supports format-date. To get the date formatted as you originally requested, you will want to use something like this: format-date(${myDateQuestion},'%Y/%m/%d %H:%M'). You can add this expression to a calculation column for example, and keep the output in a text, note or  hidden question.

 I updated the original https://community.esri.com/groups/survey123/blog/2016/04/17/dates-and-time-in-survey123-for-arcgis  post with details on the new format-date function. I hope this helps!

Ismael

View solution in original post

20 Replies
IsmaelChivite
Esri Notable Contributor

Would you be willing to store the date in a separate question, for example using a Calculate type of question?

That is: you would keep your Date type of question (would be stored as an esriFieldTypeDate) and add an additional question of type calculate which would be stored as an esriFieldTypeString. If you would not mind this solution, we could help by providing you with the means to format date objects into the string question (the calculate).

At this moment in time we do not support the format-date(date, format) operation but we could consider adding this operation if you  think the solution described above would work for you.

0 Kudos
bobwright
Frequent Contributor

Hi Ismael,

Thanks for the prompt response. Yes that would work fine for me. Thanks for the offer. I actually started down that road and got as far as converting it to a string. I wasn’t sure how to proceed from there. You’ll see that in the attached spreadsheet. And while we’re at it, I would also like it to be a hidden attribute; I need it but the end user does not.

Bob

Bob Wright|GIS Specialist/Certified Wildlife Biologist

Phone: (651) 539-3318 | robert.wright@state.mn.us<mailto:robert.wright@state.mn.us>

5463-C West Broadway, Forest Lake, MN 55025

@

0 Kudos
IsmaelChivite
Esri Notable Contributor

Hi Bob,

 the latest version of Survey123 for ArcGIS now supports format-date. To get the date formatted as you originally requested, you will want to use something like this: format-date(${myDateQuestion},'%Y/%m/%d %H:%M'). You can add this expression to a calculation column for example, and keep the output in a text, note or  hidden question.

 I updated the original https://community.esri.com/groups/survey123/blog/2016/04/17/dates-and-time-in-survey123-for-arcgis  post with details on the new format-date function. I hope this helps!

Ismael

MaureenPeniuk
Deactivated User

I am getting errors.

I have a datetime field and I have set the default to now(), so ideally I never enter data in this field, it populates automatically.

it is not hidden, nor do I want it to be hidden.

But the format is June 27, 2017 and I want to change it to 2017 June 27.

Can you tell me which fields in the excel file I change or where I would insert 

format-date(${SamplingDate},'%Y/%m/%d 

Your assistance would be appreciated.

Maureen

0 Kudos
IsmaelChivite
Esri Notable Contributor

Hi. The Date widget follows the date format specified in the regional settings of your device (your locale). Next I show what the date will look like in a device set to United States region vs Spain.

Of course, you can use the format-date() function to create a string where you can control exactly the format regardless of the regional settings, but it seems to me like in your case you really want to tweak the regional settings.

MaureenPeniuk
Deactivated User

Thanks for the swift reply!

I never would have thought to check the device settings!

I am in Canada - and for the date/time settings on my ipad I was able to

change to the 24 hour clock.

But I don't see any place to change the format from month day year to year

month day.

0 Kudos
IsmaelChivite
Esri Notable Contributor

Go to Language & Region instead of changing the Date & Time settings.  iOS lets you change the Region and the Date format is inherited from that.  I personally do not know if it is possible to manipulate the date format in iOS other than through the Region.

As you change the region, you will see the Region Format Examples.

0 Kudos
MaureenPeniuk
Deactivated User

Ah, now I get it... Spain it is !

Thanks so much Ismael!

0 Kudos
IsmaelChivite
Esri Notable Contributor

You can also force a language/locale on the form by setting the default language in the settings worksheet of  your XLSForm. For example, you can change it to es_ES  This I think it is more practical in some cases because you may not want to change the region or have field users change that.

The thing is, I do not know of any locale that would display dates as Year, Month, Day, so we may be at a loss here.  The calendar format is limited to those used in the different locales. You will need to find a locale in English that sets the format as you need... and I am not aware of any but there may be one!

0 Kudos