Hello,
We have a survey with a shift start and stop time. We need the user to enter specific times so we are using a Date type question and a separate Time type question to avoid the auto population of the time that occurs in a DateTime type question.
Is it possible to then combine the Date and Time results and combine those in a single field? I have tried a few configurations and calculations, but frequently receive a type mismatch error. I'd essentially like to replace the "default" time that gets applied to a date/dateTime field with the user input...
Here is how I envision the date and time question configuration:
type | name | bind::esri:fieldType |
date | ShiftStartDate | null |
time | ShiftStartTime | null |
Here is a calculation I have tried for reference of what I am trying to achieve:
type | name | calculation | bind::esri:fieldType |
text | ShiftStart | string(format-date($ShiftStartDate, "%m/%d/%Y")) + " " + string(format-date($ShiftStartTime, "%h:%M")) | esriFieldTypeString |
I am open to the ShiftStart field being date or string type in the service. Thank you!
Solved! Go to Solution.
Hello @JBeasley,
You will need to use the concat() function to merge the strings together as opposed to the plus sign. With the plus sign Survey123 is trying to perform a mathematical addition with the values. The calculation would look like:
concat(string(format-date($ShiftStartDate, "%m/%d/%Y")), " ", string(format-date($ShiftStartTime, "%h:%M")))
Hello @JBeasley,
You will need to use the concat() function to merge the strings together as opposed to the plus sign. With the plus sign Survey123 is trying to perform a mathematical addition with the values. The calculation would look like:
concat(string(format-date($ShiftStartDate, "%m/%d/%Y")), " ", string(format-date($ShiftStartTime, "%h:%M")))
Hi @ZacharySutherby ,
Thank you for the reply! I found the issue was likely due to missing curly brackets around my field name. The concat did work- thanks.
This was my final calculation formula:
if(string-length(${ShiftStartTime})!=0, concat(string(format-date(${ShiftStartDate}, "%m/%d/%Y")), " ", string(format-date(${ShiftStartTime}, "%H:%M"))), "")