<?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: Datetime.now() No Longer Working Python 3.7.9 in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1022653#M36764</link>
    <description>&lt;P&gt;Finally figured this out. I'm updating two nearly identical datasets, one for the web and one in local projection for printed maps. The local dataset lacks a Global ID field, so the indexs were off by one and the script was trying to put a date in a non-date field. It's strange that this hasn't been an issue before.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Feb 2021 18:03:50 GMT</pubDate>
    <dc:creator>LeviCecil</dc:creator>
    <dc:date>2021-02-02T18:03:50Z</dc:date>
    <item>
      <title>Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021255#M36550</link>
      <description>&lt;P&gt;I have a script that automatically updates a sync enabled sde feature class. I populate the last_edited_date field with datetime.now(). This has worked for over a year until last week. All of a sudden I'm getting this &lt;STRONG&gt;error&amp;nbsp;RuntimeError: The value type is incompatible with the field type. [last_edited_date].&amp;nbsp;&lt;/STRONG&gt;Not sure what's going on. The date field in the feature class is in this format:&amp;nbsp;&lt;STRONG&gt;%m/%d/%Y %H:%M%p&amp;nbsp;&lt;/STRONG&gt;or&amp;nbsp;1/28/2021 1:05 PM.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Datetime.now() prints this format:&amp;nbsp;&lt;STRONG&gt;2021-01-28 13:06:30.180737&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 21:07:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021255#M36550</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-01-28T21:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021262#M36553</link>
      <description>&lt;P&gt;did you perhaps switch from python 2.7 to 3.x (aka arcmap to arcgis pro, or within SDE)&lt;/P&gt;&lt;P&gt;As for the international formatting issue, you now have nanosecond precision.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.python.org/3/library/datetime.html" target="_blank"&gt;datetime — Basic date and time types — Python 3.9.1 documentation&lt;/A&gt;&amp;nbsp; just select the 3.7 docs when you are there for changes if this is your case&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 21:21:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021262#M36553</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-28T21:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021277#M36556</link>
      <description>&lt;P&gt;Nothing changed. The script runs every Monday and it errored out this week.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 21:33:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021277#M36556</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-01-28T21:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021341#M36565</link>
      <description>&lt;P&gt;What RDBMS are you using and what release of ArcGIS Enterprise are you using as well?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 23:16:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021341#M36565</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2021-01-28T23:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021342#M36566</link>
      <description>&lt;P&gt;As far as the sde database management, I’m doing it all in Pro. We’re on enterprise 10.7.1.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 23:19:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021342#M36566</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-01-28T23:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021344#M36568</link>
      <description>&lt;P&gt;Thx for the info on ArcGIS Pro and ArcGIS Enterprise 10.7.1.&amp;nbsp; Are you using Oracle, SQL Server, PostgreSQL, etc for your RDMBS?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 23:21:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021344#M36568</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2021-01-28T23:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021349#M36571</link>
      <description>&lt;P&gt;Sorry, SQL Server.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 23:29:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021349#M36571</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-01-28T23:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021354#M36575</link>
      <description>&lt;P&gt;&lt;A href="https://support.esri.com/en/technical-article/000013224" target="_blank"&gt;FAQ: What version of Python is used in ArcGIS? (esri.com)&lt;/A&gt;&amp;nbsp; which python is default?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 23:55:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021354#M36575</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-28T23:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021355#M36576</link>
      <description>&lt;P&gt;I’m on Pro 2.7, so Python 3.7.9&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 23:58:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021355#M36576</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-01-28T23:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021357#M36577</link>
      <description>&lt;P&gt;its more the server side that I was wondering, not Pro&lt;/P&gt;&lt;LI-CODE lang="python"&gt;f = '%m/%d/%Y %H:%M%p'

nw = datetime.datetime.now()

nw.strftime(f)
'01/28/2021 19:19PM'&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 29 Jan 2021 00:20:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021357#M36577</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-29T00:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021540#M36598</link>
      <description>&lt;P&gt;Thx Levi - I agree with Dan that I think this is on the RDBMS/Server side.&amp;nbsp; What release of SQL Server are you using?&amp;nbsp; The only related item I found on the "internals" was for Oracle - could be related or not.&amp;nbsp; See below for the Oracle resolution:&lt;BR /&gt;&lt;BR /&gt;"&lt;SPAN&gt;After researching I found the reason for the error and a possible solution. Beginning with ArcGIS 10.4 we started to notice a problem making selections on the date fields. The problem was a wrong SQL statement. The solution was adding "TO_CHAR" before the date field in the select query. This addition converts the date field into a string that works with our software. I suggest adding "TO_CHAR(vc.AdmitDt)," to your select query and checking if the selection works before running the insert. Attached is a screen capture of how the select script should look. Also see Oracle document for better formatting instructions."&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 15:56:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1021540#M36598</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2021-01-29T15:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1022243#M36715</link>
      <description>&lt;P&gt;So even weirder, the script is actually updating the feature with the current datetime, but I'm still getting that error before the script finishes running:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edit.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5038i43D385A56C9A3010/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edit.PNG" alt="edit.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edit2.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5039iB2B6D5DECD2C9E68/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edit2.PNG" alt="edit2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is my script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests
import json
import os, sys
import arcpy
import datetime

##This script checks Tririga for modifications to spaces/rooms in the last week.
##If modifications are found, space attributes are updated in the
##Rooms with Space ID sde feature class.

datetime = datetime.datetime.now()

##Query Tririga for spaces with recent modifications
tririga_mods_url = "https://&amp;lt;tririgaserver&amp;gt;/oslc/spq/PPSspaceModQC?oslc.select=*"
payload = {'USERNAME': 'user', 'PASSWORD': 'password'}
request = requests.get(tririga_mods_url,params=payload)
result = json.loads(request.text)
##print(json.dumps(result, indent=2)) ##prettify json
##sys.exit()
jsonData = result["rdfs:member"]

triSystemID_List = ['10423582',]

##Append Tririga System IDs to empty list

for entry in jsonData:
    triSystemID = entry['spi:identifier']
    triSystemID_List.append(triSystemID)
##print(triSystemID_List)
##sys.exit()

if len(triSystemID_List) == 0:
    print("No recent space modifications")
    sys.exit()

else:
    
    ##Query Tririga for modifications in each space
    for SystemID in triSystemID_List:

        tririga_space_query_url = "https://&amp;lt;tririgaserver&amp;gt;/oslc/so/PPSspaceGIS/" + SystemID 
        request = requests.get(tririga_space_query_url,params=payload)
        result = json.loads(request.text)

        ##Tririga attributes from result dict:
        triSpaceClass = result["spi:triCurrentSpaceClass-triNameTX"]
        triSpaceClassDesc = result["spi:triCurrentSpaceClass-triDescriptionTX"]
        triSpaceID = result["spi:triIdTX"]
        triCapacity = result["spi:triDefaultCapacityNU"]
        
        triParentFloor = result["spi:triParentFloorTX"]
        triParentBuilding = result["spi:triParentBuildingTX"]
        triUsedForK2 = result["spi:cstCurrentlyUsedForK2BL"]
        triParentProperty = result["spi:triParentPropertyTX"]
        triArea = result["spi:triAreaNU"]
        triMeetsK2Criteria = result["spi:cstMeetsCriteriaForK2CommonBL"]
        if triMeetsK2Criteria == 1:
            triK2Compliant = 'TRUE'
        elif triMeetsK2Criteria == 0:
            triK2Compliant = 'FALSE'
        else:
            triK2Compliant = None
        triAltSpaceUse = result["spi:cstAlternativeSpaceUseCL"]
        triRoomNum = result["spi:triNameTX"]
        
        triParentID = result["spi:triParentIdSY"]
        triSystemID = result["spi:identifier"]

        ##connect to sync enabled sde feature class on ArcGIS server
        arcpy.env.workspace = r"C:\Connections\PPS_Enterprise_Prod.sde" 
        arcpy.env.overwriteOutput = True
        rooms_web = "PPSProd.DBO.Rooms_w_SpaceID_All_Sites_WEB"
        rooms_harn = "PPSProd.DBO.Rooms_w_SpaceID_All_Sites"
        rooms_list = [rooms_web,rooms_harn]
        
        ##Only find spaces in the feature class that match the Tririga SpaceID field.
        where_clause = "WHERE SpaceID = '" + triSpaceID +  "'"

        for fc in rooms_list:
            
            with arcpy.da.UpdateCursor(fc, '*', where_clause) as cursor:

                ##sde feature class attributes 'fc'
                
                for row in cursor:


                    fcSpaceID = row[2]
                    fcSiteName = row[5]
                    fcRoomNum = row[6]
                    fcK2Compliant = row[7]
                    fcSpaceClass = row[8]
                    fcArea = row[9]
                    fcEditUser = row[13] ## last_edited_user field
                    fcEditDate = row[14] ## last_edited_date field
                    fcRoomDescription = row[16]
                    fcAlternateUse = row[17]
                    ##fcCapacity = row[18]
                  
            
                ##update feature class with attrubute data from Tririga 'tri'

                    if (row[:20] != [triRoomNum,triSpaceClass,triArea,
                                     triK2Compliant, ##triCapacity,
                                     triAltSpaceUse,triSpaceClassDesc]):
                        row[6] = triRoomNum
                        row[7] = triK2Compliant
                        row[8] = triSpaceClass

                        if fcArea - triArea &amp;gt; 1.0 or fcArea - triArea &amp;lt;= -1.0 :
                            row[9] = triArea
                        else:
                            row[9] != triArea
                       
                        row[13] = "GIS Admin"
                        row[14] = datetime
                        row[15] = triSpaceClassDesc
                        row[16] = triAltSpaceUse
                        ##row[18] = triCapacity

                        print("Updating " + triParentProperty + " Room Number " + triRoomNum + " in " + fc)
                        cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 19:10:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1022243#M36715</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-02-01T19:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1022328#M36727</link>
      <description>&lt;P&gt;We're on SQL Server 2019&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 22:00:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1022328#M36727</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-02-01T22:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime.now() No Longer Working Python 3.7.9</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1022653#M36764</link>
      <description>&lt;P&gt;Finally figured this out. I'm updating two nearly identical datasets, one for the web and one in local projection for printed maps. The local dataset lacks a Global ID field, so the indexs were off by one and the script was trying to put a date in a non-date field. It's strange that this hasn't been an issue before.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2021 18:03:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/datetime-now-no-longer-working-python-3-7-9/m-p/1022653#M36764</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-02-02T18:03:50Z</dc:date>
    </item>
  </channel>
</rss>

