formatting time within a (decimal-date-time()) statement

1082
1
08-24-2020 01:31 PM
LeonardBarnhill
Occasional Contributor

I am developing in Survey123 Connect version 3.10.239.

 

My goal is to let a user know when the inspection of a structure is to be repeated. I start with a field ${currinspdate} that is by default now().  I give the user a choice of inspection frequency (i yr, 3 yr, 5 yr, and 10 yr) and I want the results to be in a traditional Mon dd, YYYY format.  The results are currently a number.  I have tried  date(decimal-date-time(formatDate)+365) formula and get a number but cannot get this in Mon dd, YYYY format.    I have tried breaking it down to just date(decimal-date-time(now()+365) but get the same numeric results. 

I created a calculate type field with the calculation format-date(${currinspdate}, '%b %d, %Y"), then trying the format date(decimal-date-time (${currinspdate} + 365). Error message "ReferenceError: formatDat"

Suggestions?  

What is odd?  This formula worked in an older RC version using the entire formula:

if(${MONITOR}='1YR',date(decimal-date-time(now()+365),if(${MONITOR}='3YR',date(decimal-date-time(now())+1095),if(${MONITOR}='5YR',date(decimal-date-time(now())+1825),date(decimal-date-time(now())+3650))))

In the attachment look toward the bottom for the section monattr  Next Inspection Schedule.  Todays Date is captured at the very beginning currinspdate defaults to now()

1 Reply
LeonardBarnhill
Occasional Contributor

FIXED:  I guess I just needed to type it out to track what I had tried.

I inserted a new calculate type field named nextinspcalc between MONITOR and NEXTINSP and moved the long IF statement to the calculation column.  In the NEXTINSP calculation column, I added the formula format-date(${nextdatecalc}, '%b %d, %Y').

The calculate type added on row 3 has been deleted since it was contributing nothing to the solution.

Now works like it did before.  I hope this helps someone else also