How to format Date-time results from Search() function...

427
2
03-25-2023 11:47 AM
MiltonSolano
Occasional Contributor

Hi Folks,

I'm building a survey for boats reservations where our users will select from a list of available schedules (Date-time) from another survey to register.

I can search for the available scheduled dates using the Search() function. The returning string is an epoch time. See the attached screenshot.

My question is: how can I format this date to show it as a regular Date-time value? This is how I'm retrieving the available dates:

RegisterTravel.png

What function should I use in the appearance column? I tried using format-date or decimal-date-time functions with no luck. Is this even possible?

Cheers,

Milton

0 Kudos
2 Replies
ZacharySutherby
Esri Regular Contributor

Hello @MiltonSolano

The Search() appearance is going to display values as they are returned by the server. When date fields are queried from the feature service they are returned in epoch timestamps which is why it's displayed like that in Survey123. What I would suggest is in your initial registration survey adding a hidden or calculate field to store the formatted date as a string in the feature service, then use that string field in the search() appearance. 

Thank you,
Zach
MiltonSolano
Occasional Contributor

Thank you @ZacharySutherby  for taking the time to answer. It sounds more like a hack than a proper solution. What about if I need to search in a range of dates? Or search after a specific time frame within a date? Using strings is not possible.

None of the search samples uses date datatype as filter. The date datatype is key in searches and the hack you mentioned probably work but it requires a little bit more overhead to work properly.

Anybody has other ideas?

Milton

0 Kudos