<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calculation year formula? in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/calculation-year-formula/m-p/1210634#M44722</link>
    <description>&lt;P&gt;The problem has occurred because he has changed the question type. He may not have changed the calculation field, but in version 2 the answer is clearly being returned as an integer/text, while in version 3 it is being returned as a date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If he changes the [type] field for ${Fert year} back to "integer" it will work just fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;A [date] type question will always return the full Y_M_D string. Even if you ask for the answer as a YYYY string in the calculation, using the [date] question type will just add back the other fields as 0 or 1 values. So 2022-09-08 gets reduced to a string off 2022, then converted back to 2022-01-01.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So what your friend has done is asked the app to convert the year to string using &amp;nbsp;format-date, and then asked it format that string as a Y_M_D date by using the [date] type. He has then asked it to subtract the integer from the date 2022-01-01. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Of course the result of that is nonsense. So the app can't return a valid date value, and instead then returns the default epoch date- 31-12-1969&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Sep 2022 02:24:01 GMT</pubDate>
    <dc:creator>LaurenceTait</dc:creator>
    <dc:date>2022-09-08T02:24:01Z</dc:date>
    <item>
      <title>Calculation year formula?</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/calculation-year-formula/m-p/1210374#M44700</link>
      <description>&lt;P&gt;I am posting for a coworker. He is using Connect version 3.13.&lt;/P&gt;&lt;P&gt;He has a field that is calculated with the formula &lt;STRONG&gt;format-date(today(), '%Y')-${repeat_no}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In an older version it works fine. Example below.&lt;/P&gt;&lt;P&gt;Version 2&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Alena_0-1662561369476.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/50634iC99BCDD56CA2FD11/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Alena_0-1662561369476.png" alt="Alena_0-1662561369476.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;He made a new version and did not change this field but now he gets December 1969.&lt;/P&gt;&lt;P&gt;What happened?&lt;/P&gt;&lt;P&gt;version 3&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Alena_1-1662561369478.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/50633i4E23A8EC388AC9DA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Alena_1-1662561369478.png" alt="Alena_1-1662561369478.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 14:43:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/calculation-year-formula/m-p/1210374#M44700</guid>
      <dc:creator>Alena</dc:creator>
      <dc:date>2022-09-07T14:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation year formula?</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/calculation-year-formula/m-p/1210634#M44722</link>
      <description>&lt;P&gt;The problem has occurred because he has changed the question type. He may not have changed the calculation field, but in version 2 the answer is clearly being returned as an integer/text, while in version 3 it is being returned as a date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If he changes the [type] field for ${Fert year} back to "integer" it will work just fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;A [date] type question will always return the full Y_M_D string. Even if you ask for the answer as a YYYY string in the calculation, using the [date] question type will just add back the other fields as 0 or 1 values. So 2022-09-08 gets reduced to a string off 2022, then converted back to 2022-01-01.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So what your friend has done is asked the app to convert the year to string using &amp;nbsp;format-date, and then asked it format that string as a Y_M_D date by using the [date] type. He has then asked it to subtract the integer from the date 2022-01-01. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Of course the result of that is nonsense. So the app can't return a valid date value, and instead then returns the default epoch date- 31-12-1969&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 02:24:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/calculation-year-formula/m-p/1210634#M44722</guid>
      <dc:creator>LaurenceTait</dc:creator>
      <dc:date>2022-09-08T02:24:01Z</dc:date>
    </item>
  </channel>
</rss>

