Select to view content in your preferred language

survey123 time field - select seconds not just hours/minutes

1613
5
05-26-2019 03:52 AM
GeomaticsPublisher
Occasional Contributor

Hi,

I'm creating a survey123 form using survey123connect (3.4 beta) and I need to be able to drill down into seconds as an option for data entry in a time field. As default the user can only select the hours and minutes for a time field and I can't find anyway of changing this. Does anyone know if this is possible?

thanks

5 Replies
JamesTedrick
Esri Esteemed Contributor

Hi,


Seconds capture is not directly supported.  It is possible to have a form with:

1) A Time/DateTime question to record information to the minute

2) An integer field to record the seconds

3) A calculate question that adds the first to questions together

  - If using a time question (which stores text), use concat() to add it to the time string

  - If using a datetime question, add (# of seconds*1000) to the datetime question

0 Kudos
FRSadmin
Occasional Contributor

Hello James, 

Is this feature still unsupported? Many natural and wildlife surveys need seconds and it would be very helpful to have in one location

JamesCrandall
MVP Frequent Contributor

Hi, 

We were trying to find a way to use the seconds value from a datetime for other use (concatenate into another value) and thought you may find this useful.  The simplest method was to use the scripts component accessible in Connect and then added the pulldata functionality to acquire the seconds from the script.

  • Open the survey in Connect and add a new script:

 

function getSeconds() {
	    const padL = (nr, len = 2, chr = `0`) => `${nr}`.padStart(2, chr);
	    var currentDateTime = new Date( now() );
        var resultInSeconds=padL(currentDateTime.getSeconds());
        return `${resultInSeconds}`;
}​

 

 

  • Save it as getSeconds.js
  • In your XLSForm field, access the seconds value by applying pulldata function like so,

                string(pulldata("@javascript","getSeconds.js","getSeconds"))

  • The Javascript should also pad any digit 1-9 with a leading zero.
MaryGraceMcClellan
Regular Contributor

This is really cool -- Do you just add the seconds to the UTC time recorded by Survey123? I'm trying to do a start time/end time field so I can calculate elapsed times, but I'm only getting minutes so I'm going to try to use your script to incorporate seconds. 

0 Kudos
AlexSteiner
Emerging Contributor

I second FRSadmin's comment - it would be very beneficial to have seconds and milliseconds included in the DateTime question type.

 

Thanks! 

0 Kudos