I am creating a form for use by field personnel to use during hydrant flushing. Along with other data I want to capture how long the hydrant flushed. I am thinking i can put two questions in my survey asking start time and end time. I would like to auto populate this field with the current time when the hydrant is opened rather then when the survey is started, then again capture the time when the hydrant is closed. Can this be done or are my field guys going to have to dial in the times manually. Then I need to calculate the duration of flush (this could be minutes to over an hour) so I can multiply by the flow rate to measure the water used during flushing. Can this be done in Survey123 or will I need to do this on the back end. Any help is appreciated.
Solved! Go to Solution.
Hi.
To set the default value of a time question to the current time, you can use the expression now().
You can also calculate the number of minutes or hours elapsed between two moments in time, right from your mobile device. You will find some information about this in the https://community.esri.com/groups/survey123/blog/2016/04/17/dates-and-time-in-survey123-for-arcgis blog post. For example, you can calculate the time elapsed in minutes between two Date/Time objects by using this expression:
int(${TimeLunchEnds} - ${TimeLunchStarts}) div (1000*60)
The result of the calculation above can be shown to the user in the form or alternative be hidden from the user (but still stored in the database).
As described in the blog post referenced, Date/Time calculations use EPOCH time (milliseconds since 1970). This is the case for Survey123 for ArcGIS version 1.x We are currently working on version 2.0 where the time calculations will be done in Decimal Time. We will write in depth about this change in a couple of weeks. If you happen to build a calculation with Date/Time using EPOCH operations (as above) you will want to stay tuned for this change to Decimal Date in 2.0.
Hi.
To set the default value of a time question to the current time, you can use the expression now().
You can also calculate the number of minutes or hours elapsed between two moments in time, right from your mobile device. You will find some information about this in the https://community.esri.com/groups/survey123/blog/2016/04/17/dates-and-time-in-survey123-for-arcgis blog post. For example, you can calculate the time elapsed in minutes between two Date/Time objects by using this expression:
int(${TimeLunchEnds} - ${TimeLunchStarts}) div (1000*60)
The result of the calculation above can be shown to the user in the form or alternative be hidden from the user (but still stored in the database).
As described in the blog post referenced, Date/Time calculations use EPOCH time (milliseconds since 1970). This is the case for Survey123 for ArcGIS version 1.x We are currently working on version 2.0 where the time calculations will be done in Decimal Time. We will write in depth about this change in a couple of weeks. If you happen to build a calculation with Date/Time using EPOCH operations (as above) you will want to stay tuned for this change to Decimal Date in 2.0.
Is there a way to auto calculate the number of minutes between the start and end fields of the survey? Essentially calculating the number of minutes were spent between the user opening the survey and completing the survey?
Hi Eoin,
Yes, you can create a calculate question that subtracts the start time from the end time. Note that the results currently are milliseconds - the answer will need to be divided by 60*1000 (60 sec/min * 1000 ms/sec) to generate minutes. Additionally, please note that we are planning to switch the behavior of date fields so that the results will be in days (and thus need to get multiplied by 24*60) in a post-2.0 release of Survey123.
We have the same question. I don't think this has been answered yet, and we'd like to know if this is possible. Within our form, we want multiple timestamps:
If we enter now() in all four fields, the same time is populated. We'd like an easy way to update to the current time for fields 2 through 4 without our endusers needing to look at their watch and scroll to the new time.
Hi J.P.,
The behavior of a question with a calculation of now() will be updated in 2.5 to allow recalculation to the current time (not just the time the form started).
I thought I’d post this just in case it was of any use to others.
The latest Great Wall release has fixed the behaviour of now() so that it re-calculates. This means that if you clear a time field with now() in the calculation field and then return to enter a new value it will populate the field with the current time. Previously I think it would return the time when the form was first loaded.
For our purposes (and as has been mentioned by others in this and other threads) we wanted to take time stamps at particular points in the survey. Using the latest fix and select_one fields we’ve come up with one way you can essentially check a box and record the time when it happened.
What we did:
1) Create a select_one field in the survey (labelled something like ‘Take time now’) which has a single choice value with a name of ‘0’ (it can be labelled something more user-friendly).
2) Create a time field that you want to be populated with the current time at the desired point.
3) For that time field, under the calculation column, put in; now()+int(${TakeTimeNow’}) – i.e. you’re effectively adding zero to the current time.
Now when the select-one is checked the time is recorded. If you un-check and re-check the box it will update the time at the re-check, so people can amend things if they accidentally selected it too soon.
There may well be other/neater ways of doing this, but it worked for us.
A big ‘thank you’ to everyone who worked on the latest release – the fixes are definitely appreciated here.