Select to view content in your preferred language

Create date object from data and time questions

74
2
Jump to solution
Thursday
ChuckS
by
Occasional Contributor

I have a survey with date time questions. I need the result of those questions to be strings in AGOL. Now, I need to add a datetime object (from the date time questions) to my feature service. Does anyone know how to do this? I've looked at some documentation but, I'm not seeing a solution. I'd also like to be able to output the date object in the survey using a note.

I've attached my attempt at doing this in an XLSForm.

Thanks

0 Kudos
1 Solution

Accepted Solutions
Neal_t_k
MVP Regular Contributor

Date and datetime questions are stored as date type fields while time type questions are stored as a string.  That makes it really tough to combine the 2 questions to make calculations.  It can be done but sometimes because of the different field types they interact in strange ways. Unless you can't change your form, I would suggest looking at using a datetime question and make your calculation from there.

Dates and Time in Survey123 - Esri Community

 

View solution in original post

0 Kudos
2 Replies
Neal_t_k
MVP Regular Contributor

Date and datetime questions are stored as date type fields while time type questions are stored as a string.  That makes it really tough to combine the 2 questions to make calculations.  It can be done but sometimes because of the different field types they interact in strange ways. Unless you can't change your form, I would suggest looking at using a datetime question and make your calculation from there.

Dates and Time in Survey123 - Esri Community

 

0 Kudos
ChuckS
by
Occasional Contributor

@Neal_t_k Thanks for your response. Yes, using the datetime question is the solution! Late yesterday, I installed the Dates and Times sample survey and realized that I should be using the datetime question. (I almost started using JavaScript to calculate my date object; I'm glad I didn't take that route.)

Originally, I used separate date and time questions because I needed separate date and time strings in local time, but I can get both of those (using format-date) from the result of the datetime question. Using the datetime question, I'll add a new date field in AGOL which was my main goal.

I will still need to populate the new date field in AGOL for old records, but I see that I do that in Python using a calculated field.

0 Kudos