<?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: String to Date conversion help in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63040#M5106</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I need to calculate a date field of a FGDB raster catalog (but I guess it could be any table or fc for that matter).&amp;nbsp; The field I need to convert is a string that contains date values in the format: '2013-09-23 10:01:50' or for your Python referenced format it is: '%Y-%m-%d %H:%M:%S'&lt;BR /&gt;&lt;BR /&gt;My problem is that (I think) the ESRI Date field has trouble with really early dates.&amp;nbsp; For example, this how could I correctly set a date field value with this string:&lt;BR /&gt;&lt;BR /&gt;'0001-01-01 00:00:00'&lt;BR /&gt;&lt;BR /&gt;Yes, that is year "1".&amp;nbsp; When I run the code below, it calculates the field but this example value above is set to '1/1/2001', dropping the hh:mm:ss and always starts in the 21st century.&amp;nbsp; I need the date field to save it as the original string, but stored as a date --- I am using the Time Slider to create time-series animations and it is very finicky about using dates.&lt;BR /&gt;&lt;BR /&gt;Any help is appreciated!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; fld = "_dateText_str" &amp;nbsp;&amp;nbsp;&amp;nbsp; updFld = "_dateText_str_Converted" &amp;nbsp;&amp;nbsp;&amp;nbsp; cursor = arcpy.UpdateCursor(ras) &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strVal = row._dateText_str &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dtVal = datetime.datetime.strptime(strVal, '%Y-%m-%d %H:%M:%S') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(updFld, dtVal) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row) &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The File Geodatabase date field only supports dates from 12/31/1899 forward.&amp;nbsp; I know this because the internal representation of the data is a number (exposed through the Summary Statistics tool).&amp;nbsp; I know the internal representation of July 28, 2013 is 41483 days, which only allows 113 years back to day 0.&amp;nbsp; The date field does not support negative numbers internally.&amp;nbsp; I verified that the number of days between 12/31/1899 and 7/28/2013 is 41483 in Excel.&amp;nbsp; So you will not be able to use an fgdb date field to do what you want.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should be documented with the other field data type descriptions and limitations in the help, but it isn't.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Sep 2013 13:35:12 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2013-09-23T13:35:12Z</dc:date>
    <item>
      <title>String to Date conversion help</title>
      <link>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63039#M5105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to calculate a date field of a FGDB raster catalog (but I guess it could be any table or fc for that matter).&amp;nbsp; The field I need to convert is a string that contains date values in the format: '2013-09-23 10:01:50' or for your Python referenced format it is: '%Y-%m-%d %H:%M:%S'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My problem is that (I think) the ESRI Date field has trouble with really early dates.&amp;nbsp; For example, this how could I correctly set a date field value with this string:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;'0001-01-01 00:00:00'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, that is year "1".&amp;nbsp; When I run the code below, it calculates the field but this example value above is set to '1/1/2001', dropping the hh:mm:ss and always starts in the 21st century.&amp;nbsp; I need the date field to save it as the original string, but stored as a date --- I am using the Time Slider to create time-series animations and it is very finicky about using dates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help is appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; fld = "_dateText_str" &amp;nbsp;&amp;nbsp;&amp;nbsp; updFld = "_dateText_str_Converted" &amp;nbsp;&amp;nbsp;&amp;nbsp; cursor = arcpy.UpdateCursor(ras) &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strVal = row._dateText_str &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dtVal = datetime.datetime.strptime(strVal, '%Y-%m-%d %H:%M:%S') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(updFld, dtVal) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row) &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Sep 2013 13:16:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63039#M5105</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2013-09-23T13:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date conversion help</title>
      <link>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63040#M5106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I need to calculate a date field of a FGDB raster catalog (but I guess it could be any table or fc for that matter).&amp;nbsp; The field I need to convert is a string that contains date values in the format: '2013-09-23 10:01:50' or for your Python referenced format it is: '%Y-%m-%d %H:%M:%S'&lt;BR /&gt;&lt;BR /&gt;My problem is that (I think) the ESRI Date field has trouble with really early dates.&amp;nbsp; For example, this how could I correctly set a date field value with this string:&lt;BR /&gt;&lt;BR /&gt;'0001-01-01 00:00:00'&lt;BR /&gt;&lt;BR /&gt;Yes, that is year "1".&amp;nbsp; When I run the code below, it calculates the field but this example value above is set to '1/1/2001', dropping the hh:mm:ss and always starts in the 21st century.&amp;nbsp; I need the date field to save it as the original string, but stored as a date --- I am using the Time Slider to create time-series animations and it is very finicky about using dates.&lt;BR /&gt;&lt;BR /&gt;Any help is appreciated!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; fld = "_dateText_str" &amp;nbsp;&amp;nbsp;&amp;nbsp; updFld = "_dateText_str_Converted" &amp;nbsp;&amp;nbsp;&amp;nbsp; cursor = arcpy.UpdateCursor(ras) &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strVal = row._dateText_str &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dtVal = datetime.datetime.strptime(strVal, '%Y-%m-%d %H:%M:%S') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(updFld, dtVal) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row) &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The File Geodatabase date field only supports dates from 12/31/1899 forward.&amp;nbsp; I know this because the internal representation of the data is a number (exposed through the Summary Statistics tool).&amp;nbsp; I know the internal representation of July 28, 2013 is 41483 days, which only allows 113 years back to day 0.&amp;nbsp; The date field does not support negative numbers internally.&amp;nbsp; I verified that the number of days between 12/31/1899 and 7/28/2013 is 41483 in Excel.&amp;nbsp; So you will not be able to use an fgdb date field to do what you want.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should be documented with the other field data type descriptions and limitations in the help, but it isn't.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Sep 2013 13:35:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63040#M5106</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-09-23T13:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date conversion help</title>
      <link>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63041#M5107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The File Geodatabase date field only supports dates from 12/31/1899 forward.&amp;nbsp; I know this because the internal representation of the data is a number (exposed through the Summary Statistics tool).&amp;nbsp; I know the internal representation of July 28, 2013 is 41483 days, which only allows 113 years back to day 0.&amp;nbsp; The date field does not support negative numbers internally.&amp;nbsp; I verified that the number of days between 12/31/1899 and 7/28/2013 is 41483 in Excel.&amp;nbsp; So you will not be able to use an fgdb date field to do what you want.&lt;BR /&gt;&lt;BR /&gt;This should be documented with the other field data type descriptions and limitations in the help, but it isn't.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Richard!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm open to suggestions on where to go from here.&amp;nbsp; I have 500 rasters in a raster catalog with a name sequence starting at "0001" and go thru to "0500".&amp;nbsp; I had hoped to use this as a Year value, which I could then use in time enabled properties and get it to animate based upon this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Sep 2013 13:44:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63041#M5107</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2013-09-23T13:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date conversion help</title>
      <link>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63042#M5108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If that's how you want to use the date field (not worrying about real date), add 2000 to each seems to be a easy solution. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Sep 2013 16:33:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63042#M5108</guid>
      <dc:creator>ZachLiu1</dc:creator>
      <dc:date>2013-09-23T16:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date conversion help</title>
      <link>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63043#M5109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If that's how you want to use the date field (not worrying about real date), add 2000 to each seems to be a easy solution. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yep, that is the easy part!&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But this is the problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The customer says, "Why does the label start at "2001"?&amp;nbsp; It should be "0001"!".&amp;nbsp; Since the dynamic time display label is based upon the date field, it cannot be manipulated or masked in a way that I could alter the 2001 to read 0001.&amp;nbsp; Maybe I am missing something simple there, but from what I have found this simply cannot be altered as needed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, for some reason the "Export to Video" is sooo clunky.&amp;nbsp; I can never get it to export individual frames (1 year is 1 frame) and it wants to skip years in irregular intervals even though I have all of the appropriate properties set on the layer and time slider.&amp;nbsp; Very frustrating when you hit preview/play and it steps thru everything correctly but when attempting to export you get a video that starts at 2000 then year 2003, 20011, 2014... etc&amp;nbsp; --- it never exports 2001, 2002, 2003...etc...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Sep 2013 16:51:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63043#M5109</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2013-09-23T16:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date conversion help</title>
      <link>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63044#M5110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay here's a solution I've arrived at:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. I use the calculated date field (it can be whatever as long as it is in sequence)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Use another attribute field (in my case I have the name of the raster) from the raster catalog layer.&amp;nbsp; Turn on labels for that guy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Remove the "Display date" from the animation (found on the time slider options menu).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I still struggle with how the sequence is set correctly in the final output/export.&amp;nbsp; It never seems consistent and I can never document how I am able to get it to export the frame-by-frame correctly (sometimes it wants to skip frames at irregular intervals for example).&amp;nbsp; I dunno, I just shut down, restarted the .mxd and reset things and amazingly it exports as intended --- incredibly frustrating to not be able to nail down why.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway -- I over-thought a lot of things on this one.&amp;nbsp; But the time-slider just gets me sometimes and pushes me in a direction that appears to be what I need but clouds what it is that really needs to be done!&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Only thing left is to figure out how to position the label -- it sits directly in the middle of the raster.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Sep 2013 19:04:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/string-to-date-conversion-help/m-p/63044#M5110</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2013-09-23T19:04:37Z</dc:date>
    </item>
  </channel>
</rss>

