Dates and Time in Survey123

108034
107
04-17-2016 10:00 AM
IsmaelChivite
Esri Notable Contributor
27 107 108K

 

[Updated June 16, 2020]

[Updated September 18, 2023]

[Updated October 25, 2023]

 

Note: In October 2023, ArcGIS Online introduced new date and time field types. We will add support for these new fields in Survey123 in 2024.  This article will be updated accordingly once we have support for the new field types. Until then, everything below applies only to esriFieldTypeDate.

 

In this blog post I will describe how you can work with dates and time in Survey123 with XLSForm. I will also cover important concepts for you to understand how dates and time are modeled in ArcGIS.

 

Before we start

To best follow instructions and concepts in this blog, I suggest you open the Dates & Time survey sample in Survey123 Connect. If you have a first look at this sample survey, it will much easier for you to follow content in the blog.

 

  1. Open Survey123 Connect
  2. Tap on New Survey
  3. Select the Samples category
  4. Scroll until you see the Dates & Time survey sample or use the search function.
  5. Create a new survey from this sample

 

Create new survey sample in survey123 Connect

 

Next, spend some time going over the survey. I suggest you explore it first in Connect and you also bring it into your phone or a web browser to see what it feels like. The structure of the blog pretty much follows the sample survey.

 

Basic Types and Appearances

496812_DatesAndTime.png

 

The Basic Types and Appearances section of the survey sample explores the different ways in which a date or time question can be presented to the end user. Combinations of the question type and its corresponding appearances, will help you control the best user input style that fits the needs of your workflow.

 

The first question in this survey is of type date and it uses no appearance. A calendar control is shown for users to pick a date.  Note that the question shows the current date by default. This is accomplished by setting the default column in the XLSForm to today().

 

The following 3 questions illustrate the use of appearances: Year, Month-Year and Week-Number.

 

  • Week-Number is the most exotic. Week numbers are often used in government and business for fiscal years and timekeeping. With this appearance, the calendar widgets will let the user pick a date and display the week number in the form.  You will also see the week numbers on the side as you select the date. The week numbers are calculated following the ISO-8601 standard.
  • The Year and Year-Month appearances are handy when you simply want to present the user with a choice to pick a year, or a year-month.

 

As you exercise the calendar control, it may not be obvious, but you can actually tap and hold the arrows to quickly navigate back and forth in time.

 

Survey123

  • The DateTime and Time questions are shown at the end of this first section. Note that the questions automatically show the current date and time. This is accomplished by adding he now() function into the default column.

 

Understanding Dates and Time in ArcGIS

 

The Date, DateTime and Time types of questions as well as their corresponding XLSForm appearances, help you control the user experience that you want to present to the end-user capturing the data, but it is also important to understand how that date will be stored in ArcGIS.

 

User input to the Date and DateTime questions will be persisted in ArcGIS in a field of type Date (esriFieldTypeDate).  Despite the name of this field type, ArcGIS does not store just dates in Date fields: ArcGIS date values always include time as well. Hence, there is a perfect match between DateTime questions in Survey123 and ArcGIS date fields, but when it comes to date questions in Survey123, you need to understand that actually the time will also be stored.   But what time? Well, it depends:

 

  • The time will be noon (12:00PM) if the user has manually selected a date, or if you set the date using the today() function.
  • The time will vary if you set the date using the now() function. Now captures the current time, even if your date question does not show the time to the user in the form.

 

The screenshot below shows how you can configure a date field in your layer to display time. Note that in the Map Viewer, I had to open first the Fields dialog, then click on the date field and finally turn on the "Show time" option.   Once you do this, your popups will display time information!

 

IsmaelChivite_0-1695060726614.png

Time values in Date and DateTime questions  are always persisted as Coordinated Universal Time (UTC). This is important when you have people working in different time zones. ArcGIS clients will translate the stored UTC values into your local time zone. The only exception is ArcGIS Pro. ArcGIS Pro will show the time in UTC (unless configured to do otherwise).

 

So far, I described how date and datetime questions behave. Lets talk next about Time questions, because they are special. For Time questions, Survey123 does not use the ArcGIS date type (which we know now that actually stores date and time). Survey123 time questions store values as a string. We did it this way, because otherwise you would get dates as well, and this could be confusing: Say you want to capture the time when a store opens.... you would not want the date in there...  Now, because time is stored as a string, there is no information regarding the time zone in it. As such, you need to keep in mind that there will be no time zone conversion.  Later in the survey, we will explore how to capture times differently.

 

Date and DateTime questions store values as date objects including time. Time questions store values as text.

Formatting Dates

 

All graphical controls in the Survey123 apps will honor your locale regional settings. For example, if your browser or smartphone's locale is set to Spanish, then dates will be formatted the Spanish way (which is the correct one, by the way... just kidding).  In the next screenshot I show what the calendar control will look like in a phone set with United States vs Spain regional settings. Note that when using the Spain regional settings, the day goes first, then the month and then the year, versus the US version where the month goes first then the day and then the year.

 

Survey123 Dates English Spanish

 

Additionally the format-date and format-date-time function allow you to convert date objects into strings.

 

In the following example, we  use the wsdatetime question to capture the date and time at which a water sample was taken. The wstime question calculate will be hidden from the end-user and is used to extract the time entered and persist it as a string in military format.  Note that the output of the wsdatetimequestion is stored in ArcGIS as a date object in UTC, versus the wstime which will be stored as a string using local time in your device.

 

type name label calculation

dateTimewsdatetimeSample Date/Time 
calculatewstimeTimeformat-date(${wsdatetime},'%H:%M')

 

The qualifiers in the format-date function are as follows:

%Y4 digit year
%y2 digit year
%m0-padded  month
%nnumeric month
%bmonth name abbreviated
%d0-padded day of month
%eday of month
%H0-padded hour (24-hr time)
%hhour (24-hr time)
%M0-padded minute
%S0-padded second
%30-padded millisecond ticks (000-999)
%aThree letter short text day

 

Date and Date-Time Defaults

 

Survey123 accepts three possible values in the XLSForm default column:

 

  • today() This function returns the current date in your device. Typically you apply this function to questions of type date. The time part of this date will always by noon (12:00pm).
  • now()  This function returns the current time in your device. Typically you apply this function to questions of type datetime.
  • Finally, you can also apply a fixed date in ISO 8601 notation. For example: 2020-06-23T00:00:00-07:00.
    • 2020 for the year. Always 4 numbers.
    • 06 for the month. Always 2 numbers
    • 23 for the day. Always 2 numbers
    • T is simply a separator, for time. Always T.
    • 00 for the hour. Always 2 numbers
    • 00 for the minutes. Always 2 numbers
    • 00 for the seconds. Always 2 numbers
    • -07:00 is the UTC offset, which in this case is minus 7 hours.

 

Technically, you could also apply default value using Unix epoch notation (in milliseconds), but this would only work in the Survey123 field app. For consistency across the field and web apps, it is best to use ISO 8601 notation.

 

Constraints and Calculations

 

This section of the sample survey will be useful to understand how you use formulas with dates and date-times, so you can validate user input, as well as pre-compute date values. The questions in the survey are self-explanatory, The best is that you have a look at the XLSFile to better understand how things are done.

mobapp.png

 

  • Constraints: A common constraint you will want to enforce is one that ensures a date is in the past or the future. That is pretty straight-forward: .> now() will ensure the user input is in the future for example. If you want to reference another question in the survey, you can use something like this: ${birthdate}<today(). This will ensure that the birthday question has a value in the past.

 

In constraints you may be asked to ensure a value is always newer and older than a fixed date. The date function is very useful in these cases. For example, you can set a constraint such as . > date('2006-01-01') or ${manufacture_date} > date('2006-01-01').

 

If you need to work with time constraints, simply add the time component to the date() function using the ISO 8601 notation.

 

 

  • Calculations: Calculations are easy too, as long as you understand that dates in the Survey123 app are encoded as numbers. When users pick a date or a date-time in the survey, all values will be presented in a human friendly way, but internally the application handles them as numbers that represent the total time elapsed since 1970. A positive number represents a date after 1970 and a negative number a date in the past.  As you can imagine those are pretty big numbers, but the math is simple once you understand how time is expressed. There are basically two formats for the elapsed time:

 

  • Unix epoch is the elapsed time since 1970 expressed in milliseconds.
  • Decimal date or French Revolutionary Time is the elapsed time since  1970 expressed in decimal days. That is, one day is 1.0, an hour is 1/24, a minute is 1/24/60, etc.   To learn more  about Decimal Time have a look at this 'How the French made a 10-hour day' article. You will love it!

 

 UNIX EPOCHDECIMAL DATE
2 weeks into the futurenow() + 14*24*60*60*1000date(decimal-date-time(now()) +  14)
Calculate age from birthdayint((today() - ${birth_date}) div (1000*24*60*60* 365.25))

int((decimal-date-time(today()) - decimal-date-time(${birth_date})) div 365.25)

Minutes spent for lunchint(${LunchEnd} - ${LunchStart}) div (1000*60)

int((decimal-date-time(${lunchends}) - decimal-date-time(${lunchstarts})) * 24*60)

15 minutes from nownow() + 15*60*1000

date-time(decimal-date-time(now()) +  0.0104166675)

0.0104166675 is equal to  (1 (day) / 24 (hours) / 60 (minutes) ) times 15 (minutes).

I recommend you work with decimal date format, because then your XLSForm expressions will work both in the field and web apps. The Survey123 web app ONLY supports decimal time.

If you plan to use date expressions in the web app, use the decimal-date-time function.

If you ever need to populate a Survey123 date or dateTime question using a UNIX epoch number, you can use an expression like this:

 

typenamelabelcalculation
textepochEpoch (milliseconds) 
dateTimemydateThe Datedate-time(int(${epoch}) div 86400000)

 

Calculates and Relevants

 

This section in the sample survey is very similar to the previous one, but shows some other techniques that may be handy. For example, note how a calculate question is used to get the Lunch time computed, and then that value is used in other expressions throughout the survey.   A calculate is a type of question that will let you keep the result of a calculation without having to show it to the user in the survey. 

 

You will remember that questions of type time are ultimately stored as strings in ArcGIS, however, as far as calculations go, you will treat them as numbers. That is actually pretty handy because otherwise, you would not be able to do much with them!

 

Other ways to capture Time

 

The last section in the sample survey shows other techniques to capture time.

mobapp2.png

  • The 'Time from a list' example should not come as a surprise. A select_one type of question with minimal appearance is a nice way to present a list of hours to choose from.
  • Then there are some other examples illustrating how to use regular expressions in constraints as well as input masks.  I will go into the details here, so nothing is missed.
    • First, an example to capture military type with a period. For example: 11:35.  Note the use of an input mask here. The input mask automatically adds the period (:), so the user does not have to worry about that. The value of the input mask is 99:99 meaning that we expect to digits followed by a period and two more digits. You will see that the constraint column checks to make sure that the hours do not go beyond 23 and the minutes do not go beyond 59.  Note: input masks are NOT supported in the Survey123 web app.
    • In the second example, we want to capture military time, but without the period. For example: 1135. In this case, I want to highlight a couple of things. First, note that I am not using an input mask like before. It is not needed, because we can set the type of question as integer (to ensure that only numbers can be typed) and also set the the maximum length of the field to 4. This is done through the bind::esri:fieldLength column. This will do two things: will ensure that only integers with 4 digits can be entered into the Feature Service, and most importantly, will limit the user input in the Survey, to 4 numbers.  I still added a regular expression in the constraint to ensure that proper values within the 24 hour day are entered.
    • In the third example, I want to capture military time including the time zone. For example 1445Z. Z is the time zone (ZULU, which represents UTC). In 1445G, G is for Golf and represents UTC + 7.  That would be 1445 Golf Time. How awesome is that! More details on this crazy business with Time Zone Abbreviations here. Again in this case I added a mask and complemented it with a regular expression in the Constraint.

 

If you are not familiar with input masks in Survey123 I recommend you have a look at the Esri custom columns help topic. Regular expressions are tricky to put together, but you can find loads of samples in the web.

 

Start and End

 

So far, we have been looking at date and time questions that were visible in the survey. It is for this reason that we cared about the user experience (types of questions, defaults and appearances) as well as the validation of inputs (input masks, constraints).  Now, in Survey123 there are a couple of handy question types that will capture time without the end user knowing. These questions are start and end.  When added to your survey, like in the Sample you are looking at, they will not show in the survey to the end-user, but they will populate data in the Feature Service, that you can see from the survey123 web site or a web map.

 

Start and end will capture the exact date and time at which the survey was initially opened by the end user, and flagged as done. For you to see how this works, the best is that you load the survey in your phone, complete a couple of surveys and submit the data.

 

The start and end values are useful if you want to understand how much time people in the field take to complete surveys. To calculate the duration of the survey, you will need to download the data in FileGeodatabase or Shapefile format and calculate a new field with ArcGIS for Desktop. This ArcWatch article describes how you can calculate the duration between two date fields.

 

On top of start and end, which are optional, you will always get the Creation and Last Edit date and time for every row you add from Survey123 for ArcGIS. It is important to highlight here that the Creation and Last Edit columns are handled through ArcGIS Editor Tracking. The help has a good topic on Editor Tracking in case you are not familiar with it. Do not worry about  enabling Editor Tracking in Survey123, because it is always enabled by default. This feature looks at the time when edits are made in the Feature Service not when the data is necessarily being captured or changed in the field. For example, if someone is working in the field while disconnected from the network, the start and end field will truly reflect the time when the user is working on the survey. The Creation and Edit Times will reflect the time when the data was actually submitted: May be immediately after data capture, or may be a couple days later while back in the office.

 

This was a long post, but I hope you find it useful.

107 Comments
AnastasiaKurbakovskaya1
New Contributor

I was looking for a way to show date and time in my survey in the most compact and clear way -- day, month, military time.

I was able to fix time from AM/PM civilian to 24 hr military by changing my device language settings from English (Canada) to English (UK). But that took a while to figure out!

Now I am trying to find a way to display dates in a more compact way. Right now a date box looks like this: [Tuesday, 12 Novembe...] I would much rather have a simple 11/28/2019 that is not cut off by the box borders.

In the example that Ismael Chivite has provided in The Basic Types and Appearances section, dates are displayed differently in a "Date Question" vs "DateTime Question". When I open this sample survey in my Connect, I see something different -- all dates look the same: day of the week, month, day, year. Seems like date format is not affected by device settings as much.

Anyway, I would appreciate if anyone has any advice on that!

RyanDeBruyn1
New Contributor III

NewThere is still an an issue occurring when using a calculation to set the dateTime in another questions from an initial question.   The first datetime entered gets recorded as expected,   the second one is changed from pm to am.

  • only happens in web app
  • happens when time set is between 12:00 - 12:59 pm
  • happens when using calculation to set another question

created and tested with S123 Connect v3.7.62. 

test from the web app

the dateTime value changes when set from other question. 

This is having repercussion for some longer complex client forms that rely on information in relates to be set from the top.

JamesTedrick
Esri Esteemed Contributor

Hi Ryan,

Thanks for pointing this out - the issue above was reported as affecting selecting a time, not based on the calculation.

RyanDeBruyn1
New Contributor III

Copy thanks.   I am hoping this issue can get a quick fix for a next release, this issue with the webform reading, changing, selecting, calculating the date from 12-1pm has been a continued problem.

It doesn't seem like I can attach the excel file to this post but can send if need be.

Kind regards,

-Ryan

RyanDeBruyn1
New Contributor III

HI James…

Through some additional testing this issue additionally shows up when using a default set to now() for a dateTime question. If the time is between 12:00 and 12:59PM the default value that is set gets changed to AM.

Looks like there is more to this issue that what was fixed in previous version.

Thanks!

-Ryan

JamesTedrick
Esri Esteemed Contributor

Hi Ryan,

The default value of now() gets turned into a calculation behind the scenes, so I believe this is the same issue as mentioned above.

WinleyDurham
New Contributor II

James, 

I am trying to get my exported excel sheet to display a field with the UTC time - 8 (my UTC offset it "-8"). I'm wondering what formulas in which fields on my survey connect form I should be entering to get this.

I want this calculation to be hidden to the user, so that they are simply using the automatic time on their mobile screen, and cannot see that I'm calculating the real time, minus the 8 hours on UTC on the form. 

Thank you

JamesTedrick
Esri Esteemed Contributor

Hi Winley,

As indicated in other posts in this blog, the appropriate calculation is 

now()+pulldata("@property, "utcoffset")*1000*60*60

which can be applied to either a read-only datetime question or to a calculate question that submits to a date field.

LuisMartinez3
New Contributor II

I am trying to auto populate a field based on time, basically if the time is between 8:00AM and 6:00PM return a value of 'A' otherwise give it a value of 'B.'

So if you work between certain times youre in Shift A otherwise youre in shift B.

in my calculation field i have 

if((${time} >= '8:00AM' and ${time}=<'6:00PM') 'A', 'B')

but keep getting an error. I have looked up and down for what I am doing wrong but cant figure it out. Any suggestions on what I am doing wrong?

DanteLee
Occasional Contributor II

You're missing a comma between '6:00PM') and 'A'

if((${time} >= '8:00AM' and ${time}=<'6:00PM'), 'A', 'B')
LuisMartinez3
New Contributor II

Thanks, I am still getting the same error. I went back and deleted all the fields in the bind columns just in case but there is nothing there and get the error in the image below.

typenamelabelhintconstraintconstraint_messagerequiredappearancerelevantcalculation
notelogo
dated1Date
dateTimeIncidentDateTimeTime of Incidenthorizontal
dateTimeRecordedDateTimeTime Incident Recordedyeshorizontal
select_one statusstatusIncident StatusSelect Incident Statusyesautocomplete
timetimeTime of Record Input
calculateshiftcalcAutocalculate Shifthorizontal-compactif((${time} >= '8:00AM' and ${time}=<'6:00PM'), 'A', 'B')
textshiftShift${shiftcalc}

DanteLee
Occasional Contributor II

Oh, missed it the first time through. Change =< to <=

if((${time} >= '8:00AM' and ${time}<='6:00PM'), 'A', 'B')‍
LuisMartinez3
New Contributor II

A comma and a bad operator, man, I cant thank you enough. I overlooked that 100 times! 

DelaereMickael
Occasional Contributor II

Hello thank you for this post,

Does anybody know if there is a way to format a date field with the full/long text day?

thank you

BenVan_Kesteren1
Occasional Contributor III

I see and accept that the decimal date below works, I am wanting to work out how to calculate this figure (0.0104166675) myself. For example I am now trying to work out what 7.75hr in decimal date equates too.

EPOCH FormatDecimal Date Format
15 minutes from nownow() + 15*60*1000date-time(decimal-date-time(now()) +  0.0104166675)

has anyone got any good links that could help me calculate this?

JamesTedrick
Esri Esteemed Contributor

Hi Ben,

A decimal date means that 1 day represents 1.0 units.  7.75 hours is 7.75/24 = 0.3229166666...

DataOfficer
Occasional Contributor III

How can I get my web form (created in Connect) to show the date entry in English (UK) format? It displays correctly (d/m/y) in Connect and the field app, but as m/d/y in the web form.

BenVan_Kesteren1
Occasional Contributor III

I asked the same question to ESRI Australia Tech Support, it seems to be a BUG which has been around for some time now, unresolved

JamesTedrick
Esri Esteemed Contributor

Hi Rob, Ben,

We are planning to work on the display of dates as part of our next release of Survey123 - you should be able to test in the Early Adopter Community when it is ready.

DataOfficer
Occasional Contributor III

That's great news

RoryMcPherson
New Contributor III

From skimming the above comments I think I may be having the same or a similar issue as others; I'm hoping someone has a recommendation. I'm having an issue with formatting the dateTime field, as the data seems to vary based on whether the user is using the Survey123 app, or a web browser.

I've attached several images below. Please note, Time of Departure/Return are dateTime fields defaulting to now(). Estimated Time of Return is a time field with no default.

1) Date entry within Survey123.

2) Date entry in web browser (mobile).

3) The data seems to be recorded the same, as seen in the Survey123 website data tab.

However, the formatting is not quite working or matching up depending on when a dateTime value, or time, is submitted via a web browser. This doesn't happen when using the Survey123 app though

4) As a workaround, I've tried formatting the date info within the survey form itself as a hidden text field, and then just passing the string.

In the Survey123 website data tab I seem to get an error though. The top record is data from using the Survey123 app, the bottom record from using a web browser.

Any suggestions how to tackle this? Thanks

MichaelBlakely1
New Contributor

Hi,
I'd like to confirm my understanding of a point in the original post:

Time values in Date and DateTime questions  are always persisted as Coordinated Universal Time (UTC). This is important when you have people working in different time zones. ArcGIS clients will translate the stored UTC values into your local time zone. The only exception is ArcGIS Pro. ArcGIS Pro will show the time in UTC.


If my understanding is correct, dates (dateTime and Date fields) are entered/displayed in local time in Survey123 clients (e.g. field app and web portal). However, the values stored in the feature service table are epoch milliseconds (which have to be UTC time). Is this correct?

For context, we are combining S123 data with other sources of information in an SQL server. Some date/time data is not lining up as expected and we'd like to confirm the how S123 is storing the time to take out one variable.

Many thanks

PeterGoedbloed
New Contributor III

Hi James,

I have got this calculation working. Thanks for that. I want to see the correct time both in my table in ArcGIS Online and once I export to Excel. My workflow now is to make a hidden question that applies a correction from UTC and a dateTime question that does not apply a correction. The first field displays the 'incorrect' time when viewed in the table in ArcGIS Online and the 'correct' time once exported to Excel the second field vice versa. Is this the best possible way to achieve having both times? Or am I missing something? Could this e.g. be caught in one field?

Thanks

HaroldHerrera1
Occasional Contributor

Hello

I'm trying to convert a field type "time" from a 24hour format to an AM-PM format. By default, the time field converts the time into a string and It's ok, but I need AM-PM format.

Any Idea?.

JamesTedrick
Esri Esteemed Contributor

There are 2 components to this

- Getting the hour numerically correct.  This can be done by checking if the hour is between 1 - 12; if so it is correct.  numbers larger than 12 need to have 12 subtracted; 0 needs to be 12.  This can be done with the following if() statements:
if(int(format-date(${q},'%h')) > 12, int(format-date(${q},'%h')) - 12, if(int(format-date(${q},'%h')) > 0, format-date(${q},'%h'), 12))

- Determining AM/PM - this can be done by seeing if the hour is less than 12 or greater than 11:

if(int(format-date(${q},'%h')) > 11, "PM", "AM")

Combined into a H:MM AM/PM string you have:

concat(if(int(format-date(${q},'%h')) > 12, int(format-date(${q},'%h')) - 12, if(int(format-date(${q},'%h')) > 0, format-date(${q},'%h'), 12)), format-date(${q}, ":%M "), if(int(format-date(${q},'%h')) > 11, "PM", "AM") )

HaroldHerrera1
Occasional Contributor

Hello James!

Thanks for your help, It works very good!

KelbyThomasson1
New Contributor II

James,

I have a report that I generate in a ArcGIS Pro that pulls data that is collected using Survey123 the report pulls the Date and Time, but I just need the date, my team do not want to see the time, is there a way to hide the time stamp in the report or is that something you have done before?

LuthfiAnggaraAtmaguita
New Contributor

Hi, I have an issue with the time calculation. What's the correct expression to get the time difference in minutes? (landing-takeoff=Lama Terbang)

I tried some expressions and it seemed working perfectly in the form preview in Survey123 Connect. However, after publishing it, "Lama Terbang" question won't calculate it automatically in web. One of expression I used: int((decimal-date-time(${landing_time}) - decimal-date-time(${take_off_time})) * 24*60)

What type of question that can accommodate the time calculation? Is it integers? or decimal?

LuthfiAnggaraAtmaguita_0-1624054162175.png

Another issue is in the form preview Survey123 Connect shows 24H time format, after publishing it it changed to AM-PM format. Actually it's not a big deal, as long as I can still do calculation between 2 different time.

Thanks!

PegGronemeyer1
New Contributor III

I'm looking for a way to require 1 and only 1 of 3 or 4 questions to be answered.

I created a survey for intake of a field sample - received from a variety of sources with variable date precision.  Some samples are received with an exact ddmmyy, others will say 1-14 Jun, 2021, others say June-July 2021, etc. 

Is there a way to provide different date format options but STILL make one of them required? (i.e. ensure one of the date questions is completed?)  The date the sample was found is critical, we can use the data as long as there is at least a year, even though a precise date is preferred.

I have come up with 4 date versions/questions with different precisions where user clicks on calendar to select date sample was collected - but how to make only ONE of them required?:

1. Day, month, year.  

2. Month year

3. four digit year

4. Text field for approximate date - to allow for a range such as 1-15Jun?  

Many thanks,

Peg

LisaDygert
Occasional Contributor
Hi Peg,

You can enter in if statements in the Required fields so that at least one of them is completed. You can ask questions like 'Do you know the exact date for the field sample?' If they answer yes, you can set up a relevant statement to include the option for the dd/mm/yyyy. If they say no, then you can ask if they know the month and year....so forth. So, you are most likely going to get the exact date if known, and if not at least the month and year, so forth. The options will only appear as they indicate yes or no to what information they do know and then you can make the last option the required field, so that they have to at least enter in the year.
MichaelBruening
Occasional Contributor

You could also use the "relevant" setup to only show the exact date for the answer of "Yes" and then have the Year and month be displayed when the answer is "No". The use of an if() statement for "required" or you could use this solution also - https://community.esri.com/t5/arcgis-survey123-questions/survey-123-conditionally-required-question/...

 

PegGronemeyer1
New Contributor III

Thank you for your replies.  I believe the keyword that did not occur to me was "conditional", and I'm new to Connect, so I haven't tackled relevance yet.  The link that @MichaelBruening provided is hopefully what I need.  

PanGIS
by
Occasional Contributor III

Hello!

I need to calculate a date that is "Next month from today AND always on the 10th of the month"

I followed this article and I managed to get this, which is great

How To: Apply a constraint on a date question in Survey123 Connect for ArcGIS (esri.com)

The problem is that I would like to make this valid every month.

Any idea?

PanGIS_0-1647957680623.png

 

 

PanGIS_1-1647958351632.png

thanks! 🙂

 

 

 

 

FRSadmin
New Contributor III

Hello,

I have posted my own questions to no success and have looked around on other boards (with responses) and have still not found a solution to my issue.

I do not care what the end result has to be, how can I use now() to record the time up to seconds and have it displayed in a repeat (but also editable in case they choose a new repeat item too quickly).

We are recording bird calls and need to know what time they chirp, hoot, etc.. so ideally this would function much like a stop watch where everytime I enter a new repeat it logs that time stamp.

I don`t know if there is a way to do this very initial bird call without editing the time stamp but I am at my wits end at trying to have seconds natively display in anything (even a text format question) using the now() function.

LiamHarrington-Missin
Occasional Contributor II

Hi @FRSadmin,

What an interesting use case.  Does it have to be Survey123 for this?  Your use case suggests that QuickCapture might give your users a better experience, at least for the logging of bird calls? 

That being said it doesn't allow for the need to edit the time stamp easily if you hit the button by mistake.  I guess my question would be how common this would be and whether you can just accept a small percentage of errors in an otherwise good dataset?  QuickCapture might be a way to reduce the number of spurious records as a result of a better user interface.

It's pretty simple to launch QC from within S123 as well so you could do the bulk data entry in S123 (e.g. survey metadata) and then use a hyperlink to launch QC to capture the bird calls that are clearly time critical.  Not knowing your workflow means I'm speculating about the content of your survey.

L.

FRSadmin
New Contributor III

@LiamHarrington-Missin 

I have never really used Quick Capture so I would have to look into this, does all the data get recorded in the excel file that survey123 would output?

We are trying to digitalize our wildlife surveys using PowerAutomate and right now Esri`s connector for survey123 is our best bet at lightening the out-of-office and in-office workload.

If all the base data can be pre-established and QuickCapture was launched afterwards...

From what I was shown these bird call surveys are usually for one species at a time, but alongside each time entry there is the possibility for some adjustments such as what type of call it was or if it was male / female.

What is the code in survey123 connect to pair the two if you don`t mind me asking?

I attached the form, but I am in a Japanese company so I don`t consider the titles to make much sense.Bird_Call.PNG

LiamHarrington-Missin
Occasional Contributor II

@FRSadmin,

You're right, I have to admit my Japanese is a bit rusty :).  This link will give you a starting point with integrating with the other Esri apps using a url schema.  From what you are describing, it sounds your're on the right track with having the repeat (related feature) for the bird calls vs. having a parent feature for the "base data" as you called it. 

You mention a need to get the data out in Excel.  This is of course possible but is an extra step that I tend to try and deter my users from because you can end up spending an awful lot of time trying to get an Excel Table to "sync" with the Feature Service where the data is held in AGOL.  Far easier to migrate all the downstream data analysis from an AGOL feature service (e.g. with dashboards) but that takes a bit more convincing to do.  People love their spreadsheets.

On the plus side, it is nearly automatic that data will capture the seconds, your only challenge is making it visible.  

Liam

FRSadmin
New Contributor III

@LiamHarrington-Missin 

I will certainly play around with the features to see, just from the sample surveys I can see why you would think this be more apt.

Is this data stored as a Feature Layer in AGOL?

I have to say the user interface and "tap to collect" style is exactly what my team member wanted so I just have to see if the survey template can be adjusted to it.

EricPescatore
Occasional Contributor

So in my searches, I cannot find a way to date format to include the day of the week.

In excel it's DDDD for a full date and DDD for abbreviated... yet it seems absent from supported formatting. 

The same is true of Survey123 Report formatting, which also does not include this.

With the various survey123 appearances it clearly displays the day of the week in the form element...

All i want to do is write to a string/text field to display the day, month, date, year)

Has anyone solved this conundrum and is this at all on the path. Someone from ESRI mentioned something related to dates may be improved upon.

 

RViruet
New Contributor III

@EricPescatoreYou could try formatting your date field using javascript functions.

Something like this should work for what you're trying to do.

On your xlsform, calculate column for formatted string field:
pulldata(“@javascript”, “functions.js”, “formatDateField”, ${your_date_field})

On the scripts tab:

function formatDateField(date) {
	date = new Date(date)
	let weekDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
	let months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September',
	'October', 'November', 'December'];	
	return `${weekDays[date.getDay()]} ${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
}

 

RicciLucas
New Contributor III

Hello, can someone help me figure out why my constraint is not working? I am trying to put an end date question with a constraint not to go past 3 days from the user input start date.

Here is my constraint: .<=date(${start_date} + 3)

I have also tried .<=date(decimal-date-time(${start_date}) +  3)

JavierCMartínezPrieto
Occasional Contributor

Greetings to all,

I have problems to make a calculation with the time, the problem is the following:
I have made a survey where the clockings of the workers are contemplated and I need to calculate the time of hours that are working, that is to say the subtraction between the hour of exit and the hour of entry, this operation is very simple when the record of the hour is in the same row, that is to say it is when in the survey we mark entries and we save it without sending and for the exit we edit the survey and we send it, but the operation that they want is not that but a survey is sent for the clocking in and another survey is sent for the clocking out, this causes that in the same row only has the clocking in or clocking out, causing that the working hours account does not work (clocking out - clocking in).

I am interested in doing it in a dashboard graph, more specifically in a table, I think the solution would be an arcade script but I can't do it.

any help is appreciated.
P.S: I attach an image to clarify the issue of the values in the rows.

Greetings Javier

JavierCMartnezPrieto_1-1653383616301.png

 

########################ESPAÑOL################################

saludos a todos,

tengo problemas para realizar un calculo con el tiempo, el problema es el siguiente:
he realizado una encuesta donde se contemplan los fichajes de los trabajadores y necesito calcular el tiempo de horas que están trabajando, es decir la resta entre la hora de salida y la hora de entrada, esta operación es muy sencilla cuando el registro de la hora esta en el misma fila, es decir es cuando en la encuesta marcamos entradas y lo guardamos sin enviar y para la salida editamos la encuesta y la enviamos, pero el funcionamiento que quieren no es ese sino que se envía una encuesta para el fichaje de entrada y se envía otra encuesta para el fichaje de salida, esto provoca que en la misma fila solo tenga la hora de entrada o la salida, provocando que la cuenta de horas trabajadas no funcione (hora de salida- hora de entrada).

¿alguien sabría como realizar esta calculo? me interesa realizarlo en un grafico del dashboard mas concretamente en una tabla, creo que la solución seria un script de arcade pero no consigo realizarlo.

toda ayuda es agradecida.
P.D: adjunto una imagen para aclarar el tema de los valores en las filas

Saludos Javier

JavierCMartnezPrieto_0-1653383610572.png

 

 

SomaSan2022_123
New Contributor

I have a survey; In the DateTime field, I would like to add a calculation that people can submit their permit application from 7:00 Am to 7:00 Pm. I used most of the expressions mentioned, but I keep getting errors.

I really appreciate any help you can provide.

PanGIS
by
Occasional Contributor III

Hello @IsmaelChivite and @JamesTedrick ,

sorry for tagging you but I am desperate. 😓

 

I need to find a way to calculate a date that is always next month, always on the same day of the month,  (let's say the 15th of the following month).

if I submit the survey today, the calculated date is the 15th of February.

If I submit on any day in February, that calculated day will be the 15th of March.

 

I found a way to calculate it but I need to change the date every month and this in not going to be possible.

My attempts, the first works but I have to change it manually every month, the other two are failed attempts:

https://www.dropbox.com/s/54kfbvtvg9i942q/test_Date.xlsx?dl=0

PanGIS_0-1675095628054.png

 

IsmaelChivite
Esri Notable Contributor

@PanGIS 

I hope you can use a custom JS function. This seemed to me like the most straight-forward approach.

function setNext15(inputDate) {
 var inputDate = new Date(inputDate);
 var inputMonth = inputDate.getMonth();
 inputDate.setDate(15);
 inputDate.setMonth(inputMonth + 1);
 return inputDate;
}

 

IsmaelChivite_0-1675117253824.png

 

sarazulkifly
New Contributor

 

Good day. I was hoping that anyone could be able to shed some light on the following:

I want to ensure everything is manageable; therefore, I'm setting the registration limitation at 10 people per day.

The range of possible dates is from the 10th to the 14th of March, 2023. There will be a maximum of ten people at each session.

Can anyone help me with this issue? Thank you!

 

PanGIS
by
Occasional Contributor III

Hi @IsmaelChivite  it works! ❤️

 

I believe there shouldn't be any issue as the survey is internal within the Organization and it requires login.

The lack of internet is not listed as limitation, so it can be saved in the Outbox without problems!

 

Thank you!!!  

ECanGIS_Team
New Contributor III

Hi @IsmaelChivite ,

I have hit the wall with ArcGIS Field Maps and Survey 123 and wanting to get some informations on this as you are very familiar with Survey123 Date/time. 

We have our MMPK file in enterprise system and it has got URL Construct as below: 

arcgis-survey123:///?itemID=OurSurveyID&field:most_recent_dtw={Most_Recent_DTW}&field:water_level_date={Most_Recent_Reading}&field:highest_water_level={Highest_Water_Level}&field:lowest_water_level={Lowest_Water_Level}&field:recorder_flag={recorder_flag}&field:well_no={Well_No_}&field:well_name={Well_Name}

This triggers Survey 123 to open and populate all those attribute values in there. Everythings work except {Most_Recent_Reading} which is date field. I have managed it to work in my Desktop Survey 123 when i change  {Most_Recent_Reading}  field format to mm/dd/yyyy. If I change the date format to any other format, Survey 123 in desktop populates as 1 January 1970.

While I make it to work on Desktop Survey 123 (Windows PC), I still have the same problem showing the date as 1 January 1970 on my apple device. Any clue on why this is occurring or if you are aware of Bugs with date etc?

Subodh

 

FRSadmin
New Contributor III

@IsmaelChivite @JamesTedrick 

I am still wondering if there are plans to add a seconds display feature.

I understand the data is in there, I am just curious why we can`t have that actually be displayed or adjusted with.

I have mutliple surveys that would benefit from this functionality and am really hoping this can get added.

RobertAnderson3
MVP Regular Contributor

Apologies if I missed any commentary on this in the post.

I was trying to use pulldata("@property",'utcOffset') to make sure the time zone in a report I am creating using Power Automate was correct. I notice that this pulldata provides "-3" but for the report, or in the Power Automate action settings it requires "-03" or "-03:00" format. 

I ended up using a simple if to replace "-3" with "-03" but even that feels silly to need to do.

Is there a reason that's not what the pulldata provides? Am I missing something super simple?

Thanks!