Select to view content in your preferred language

Bug in format-date function

727
5
Jump to solution
06-07-2023 05:14 PM
beachcamp
Occasional Contributor

Hello! 

 

I have created a survey that utilizes week numbers in some of it's calculations. I'm using a "calculate" field like: 

format-date(${SurveyDate}, '%W')

 

Where "SurveyDate" is simply a date field captured separately.

%W should return a week number from a given date, however it returns an error like this:

Survey123Connect_efiKHNQ1ue.png

The workaround as described here in 2018. Describes the fix as: just use a different format mask, I like %M and THEN save the XLSForm. Then in the raw XML for the form update the %Ms to %Ws as desired before publishing.

At the moment I'm in Survey123 connect 3.16, and I'm STILL dealing with this bug. I know the workaround is easy enough, but it's frustrating and does at times lead to mistakes. I just got done fixing some submissions because I published a survey update and forgot to break, then unbreak my survey via raw XML before publishing and they had incorrect week numbers.

Seeing this bug fixed would be very much appreciated. 

Thank you!

1 Solution

Accepted Solutions
ZacharySutherby
Esri Regular Contributor

Hello @beachcamp

Thank you for passing along the XLSForm! Moving the today() function from the calculation column to the default column should do the trick. 

Thank you,
Zach

View solution in original post

0 Kudos
5 Replies
ZacharySutherby
Esri Regular Contributor

Hello @beachcamp

Testing in the current release of Survey123 Connect (3.17.55) I am not seeing this behavior. If you update your Connect to the latest version is the same behavior observed? 

As a side note if you install Survey123 Connect through the Microsoft Store you will receive updates automatically when they are released. 

Thank you,
Zach
beachcamp
Occasional Contributor

Hi Zach, 

Thanks for your response. I updated to 3.17.55 and I am seeing the same error.

I created a brand new survey to verify there wasn't a version issue, with only a "date" field and a text field that should show the week number. I'm seeing the same error with that.

Attaching the sample XLSForm for testing. It's currently set to %M, which works, but changing it to %W fails.

0 Kudos
ZacharySutherby
Esri Regular Contributor

Hello @beachcamp

Thank you for passing along the XLSForm! Moving the today() function from the calculation column to the default column should do the trick. 

Thank you,
Zach
0 Kudos
beachcamp
Occasional Contributor

Well, that did seem to do the trick. Do you happen to know why this matters for %W but not other date formatting options?

0 Kudos
ZacharySutherby
Esri Regular Contributor

Hello @beachcamp

I'm glad that worked out! In theory it shouldn't like you saw with James' comment in the post you originally linked after the XLSForm is converted you could update the value in the surveys XML. The core issue is with the library that's used to convert the XLSForm to XML incorrectly throwing an error message. 

Thank you,
Zach
0 Kudos