<?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 Date format in Arcade gives wrong results in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1025760#M37231</link>
    <description>&lt;P&gt;Hi! I'm trying to understand how to generate dates using Arcade but it's quite confusing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Why does this code&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;return Date(2020,11,02);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;return a result : &lt;STRONG&gt;01.12.2020 22:00:00 &lt;/STRONG&gt;????&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get very weird results when trying to use this function &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;2. Then again, when trying to convert from string I get better results:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;var year = Year(`20201102`); //02.11.2020 -&amp;gt; November 2, 2020&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;var month = Month(`20201102`);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;var day = Day(`20201102`);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;return Date(year, month, day, 0, 0, 0, 0);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;returns&amp;nbsp;&lt;STRONG&gt;01.11.2020 22:00:00&lt;/STRONG&gt; which is almost correct, but still 1 day less than correct&lt;BR /&gt;&lt;BR /&gt;3. How to get rid from minutes - hours- second ?&lt;BR /&gt;&lt;BR /&gt;very confused&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
    <pubDate>Thu, 11 Feb 2021 10:20:59 GMT</pubDate>
    <dc:creator>kirken</dc:creator>
    <dc:date>2021-02-11T10:20:59Z</dc:date>
    <item>
      <title>Date format in Arcade gives wrong results</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1025760#M37231</link>
      <description>&lt;P&gt;Hi! I'm trying to understand how to generate dates using Arcade but it's quite confusing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Why does this code&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;return Date(2020,11,02);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;return a result : &lt;STRONG&gt;01.12.2020 22:00:00 &lt;/STRONG&gt;????&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get very weird results when trying to use this function &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;2. Then again, when trying to convert from string I get better results:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;var year = Year(`20201102`); //02.11.2020 -&amp;gt; November 2, 2020&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;var month = Month(`20201102`);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;var day = Day(`20201102`);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;return Date(year, month, day, 0, 0, 0, 0);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;returns&amp;nbsp;&lt;STRONG&gt;01.11.2020 22:00:00&lt;/STRONG&gt; which is almost correct, but still 1 day less than correct&lt;BR /&gt;&lt;BR /&gt;3. How to get rid from minutes - hours- second ?&lt;BR /&gt;&lt;BR /&gt;very confused&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 10:20:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1025760#M37231</guid>
      <dc:creator>kirken</dc:creator>
      <dc:date>2021-02-11T10:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Date format in Arcade gives wrong results</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1025763#M37232</link>
      <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/date_functions/#date" target="_blank"&gt;Date Functions | ArcGIS for Developers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/date_functions/" target="_blank"&gt;Date Functions | ArcGIS for Developers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Are you using local time or UTC time.&amp;nbsp; You first example is a date format issue/choice offset by a small time difference.&amp;nbsp; So check both and the format links as well&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 10:43:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1025763#M37232</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-11T10:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Date format in Arcade gives wrong results</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1025817#M37245</link>
      <description>&lt;P&gt;In addition to &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt; answer, when you create a date using year, month, day, the month is 0-based (0=January and 11=December)&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 13:34:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1025817#M37245</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-02-11T13:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Date format in Arcade gives wrong results</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1025836#M37251</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/422589"&gt;@kirken&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;answered your first question indicating that the month is 0 based (November would be represented by 10)&lt;/P&gt;&lt;P&gt;For the second question, I notice a couple of things. The Year, Month, and Day functions according to the documentation require a date to extract these values. You provide a string. Also, you used the names of functions for your variables and you should be careful about that. The fact that you got a result baffles me a bit, but I would not recommend taking this road.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have a text that represents a date, you will probably have to extract the different parts, convert them to numbers and then provide these numbers to the Date function correcting the month value for being 0-based.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var datetext = '20201102';
var y = Number(Left(datetext, 4));
var m = Number(Mid(datetext, 4, 2));
var d = Number(Right(datetext, 2));
Console(y);
Console(m);
Console(d);
return Date(y, m-1, d);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, Arcade does not have a&amp;nbsp;strptime() function like in Python which can convert a string to date using a provided patterns... (and yes&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;&amp;nbsp;in Python this would be a lot easier).&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 14:20:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1025836#M37251</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-02-11T14:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Date format in Arcade gives wrong results</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1026186#M37301</link>
      <description>&lt;P&gt;Thanks a lot, it's clear now!!!!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 06:34:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1026186#M37301</guid>
      <dc:creator>kirken</dc:creator>
      <dc:date>2021-02-12T06:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Date format in Arcade gives wrong results</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1278621#M67971</link>
      <description>&lt;P&gt;I have no idea why someone would decide to numerate months between 0 and 11 rather than between 1 and 12.&amp;nbsp; How does this make sense.&amp;nbsp; I guess it is not a big deal after you become familiar with this feature,&amp;nbsp; however it is very error-prone.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 01:02:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1278621#M67971</guid>
      <dc:creator>FranEvanisko</dc:creator>
      <dc:date>2023-04-14T01:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: Date format in Arcade gives wrong results</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1300723#M70356</link>
      <description>&lt;P&gt;I have just fallen foul of this, and spent the last hour or so, going over my code wondering why I'm not getting the correct results for my calculations!!!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 14:13:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/date-format-in-arcade-gives-wrong-results/m-p/1300723#M70356</guid>
      <dc:creator>DonaldMarutaNHS</dc:creator>
      <dc:date>2023-06-19T14:13:02Z</dc:date>
    </item>
  </channel>
</rss>

