Best way to collect Year data in Survey123?

2014
5
12-04-2018 07:42 AM
ChristopherMcClain
Occasional Contributor II

Sorking on a Survey123 form to collect information about fire hydrants.  One of the things I need to collect is Year Cast (Stamped on hydrant).  I am not sure the best way to do this.  Option one is to collect as a type date and then calculate the value into a non date field (integer or text).  Another is just to collect it as a integer or text to start.  Am am thinking of how to constrain the entry to a valid year (and not have to edit the survey it every year).  Also what is the bet method if input spinner, keyboard, etc. 

If anyone has an experience or advice I would appreciate the feed back.

Ismael Chivite

James Tedrick

Tags (2)
0 Kudos
5 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Christopher,

As you mention, one method would be to use a date field and use the appearance year, which provides a year picker.  If you use a text field, you could constrain the entry using an input mask (if this is not going to be used as a webform).  Additionally, using a regular expression in a constraint would make sense - take a look at regex - Regular Expression Match to test for a valid year - Stack Overflow for patterns (I would recommend the 2nd answer to limit it to certain centuries).  Finally, I might also recommend using the numbers appearance to make it easier to input digits.

ChristopherMcClain
Occasional Contributor II

If  go with the date field and appearance year.  Can I extract the year only into a separate integer field?  If so what would the calculation look like.  eventually this data will end up in a Geodatabase and linked with the an existing feature class through a relate probably a database view as well.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Christopher,

Look at the format-date() function in Formulas—Survey123 for ArcGIS | ArcGIS which can extract parts of a date (as text).  To convert to a number, you would need to the int() function as well:

int(format-date(${q}, "%Y"))

DenaS1
by
New Contributor II

James,

Is there any way to use the date type and the year appearance to get a 4 digit year in your data, without having to add a hidden row with that calculation?

int(format-date(${q}, "%Y")) worked for me if I added it to a new row in XML as a hidden data type, but not if I included it in the original line of data.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Dena,

The date type will still store a full date-time object, corresponding to January 1, <Year> 12:00.  This may be sufficient for your reporting requirement, but isn't the simple year-as-number.

0 Kudos