How to separate date and time values on Survey123?

1020
1
07-24-2020 10:20 AM
JoseBarrios1
Occasional Contributor

Hello everyone,

Does anyone have a good approach on how to capture the "date' and "time" from the Survey123 on its own fields? I have a dateTime type question on my survey that is set to now() on the default field. I like this format for the survey but I would like to capture the values separate on its own fields on the output. I took a look at Ismael great tutorial on date and time (https://community.esri.com/groups/survey123/blog/2016/04/17/dates-and-time-in-survey123-for-arcgis ) but I still couldn't figure out how to keep the dateTime format on my survey and have separate values on my output.

Thanks for any help!

JB

Tags (1)
0 Kudos
1 Reply
ZacharySutherby
Esri Regular Contributor

Hello Jose Barrios‌, 

One workflow would be to use the format-date() function to break out specific pieces of the dateTime question. If you don't want the result of the dateTime question in your feature service, and only the extracted sections you can make the dateTime question null under the bind:esri:fieldType. 

Please use the table below for an example I put together (XLSForm attached as well): 

typenamelabeldefaultcalculationbind::esri:fieldTypebind::type
dateTimetimeofsurveyTime of Surveynow()nulldateTime
notedatesectionDate Sectionformat-date(${timeofsurvey}, '%a %b %e, %Y')
notetimesectionTime Sectionformat-date(${timeofsurvey}, '%H:%M')

I had made the questions that break apart the dateTime question notes to see what the result was in Connect, but if you don't want those pieces visible in the survey you can make them hidden so that only the dateTime question is visible in the survey. On the back end only the questions that are broken out are submitted to the feature service. 

Please use the Date formatting section of this documentation for reference regarding all the qualifiers that can be used: Formulas—Survey123 for ArcGIS | Documentation 

I know you mentioned you like the formatting of the dateTime question, an alternative workflow would be to use the date and time question types independently. 

For the date question if you want the default to be now you can set the default to today() and for the time question you can set the default to now(). 

 

The XLSForm would look something like: 

 

type

name

label

default

date

insdate

date

today()

time

instime

Time

now()

 

Thank you, 

Zach

Thank you,
Zach
0 Kudos