Survey123 - Pre-populate date based on another date

728
2
Jump to solution
02-27-2020 09:21 AM
JeffDavis7
Occasional Contributor

Hello,

I've created a form using Survey123 Connect that features a date entry (as type) with a default of today()...for example it would populate the form with Thursday, February 27, 2020.  Today's date.

As an fyi...I added a new row just below this one (text as type) to reformat this date...for example the new date format is illustrated as 02/27/2020.  In using Google Sheets in tandem with Integromat it is necessary that the date be represented as such or you get a very strange entry.  Anyway...

Further down in my sheet I have another date entry.  I would like to take today's date and automatically populate this entry with a date 1 year out from today.

The auto-populate entry for that date would then read 02/27/2021.

Can this be done?

Thanks.

Jeff

0 Kudos
1 Solution

Accepted Solutions
JamesTedrick
Esri Esteemed Contributor

Hi Jeff,

Because a year can be 365 or 366 days (as it is this year), the most reliable way to set a date of one year out is to use the date() function to read in the date as a string. Assuming a date question of this_date, the formula would be:

concat(int(format-date(${this_date},'%Y'))+1,format-date(${this_date},'-%m-%dT12:00:00-08:00'))

Note the use of the UTC offset at the end of the time string.

View solution in original post

0 Kudos
2 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Jeff,

Because a year can be 365 or 366 days (as it is this year), the most reliable way to set a date of one year out is to use the date() function to read in the date as a string. Assuming a date question of this_date, the formula would be:

concat(int(format-date(${this_date},'%Y'))+1,format-date(${this_date},'-%m-%dT12:00:00-08:00'))

Note the use of the UTC offset at the end of the time string.

0 Kudos
JeffDavis7
Occasional Contributor

Thank you, James.

That's exactly what I needed.

Much appreciated!

Jeff

0 Kudos