Datetime.now() No Longer Working Python 3.7.9

1088
13
Jump to solution
01-28-2021 01:07 PM
Labels (1)
LeviCecil
Occasional Contributor III

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 error RuntimeError: The value type is incompatible with the field type. [last_edited_date]. Not sure what's going on. The date field in the feature class is in this format: %m/%d/%Y %H:%M%p or 1/28/2021 1:05 PM. 

Datetime.now() prints this format: 2021-01-28 13:06:30.180737

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LeviCecil
Occasional Contributor III

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.

View solution in original post

0 Kudos
13 Replies
DanPatterson
MVP Esteemed Contributor

did you perhaps switch from python 2.7 to 3.x (aka arcmap to arcgis pro, or within SDE)

As for the international formatting issue, you now have nanosecond precision.

datetime — Basic date and time types — Python 3.9.1 documentation  just select the 3.7 docs when you are there for changes if this is your case


... sort of retired...
LeviCecil
Occasional Contributor III

Nothing changed. The script runs every Monday and it errored out this week. 

0 Kudos
Robert_LeClair
Esri Frequent Contributor

What RDBMS are you using and what release of ArcGIS Enterprise are you using as well?

0 Kudos
LeviCecil
Occasional Contributor III

As far as the sde database management, I’m doing it all in Pro. We’re on enterprise 10.7.1.

0 Kudos
Robert_LeClair
Esri Frequent Contributor

Thx for the info on ArcGIS Pro and ArcGIS Enterprise 10.7.1.  Are you using Oracle, SQL Server, PostgreSQL, etc for your RDMBS?

0 Kudos
LeviCecil
Occasional Contributor III

Sorry, SQL Server.

0 Kudos
DanPatterson
MVP Esteemed Contributor

FAQ: What version of Python is used in ArcGIS? (esri.com)  which python is default?


... sort of retired...
0 Kudos
LeviCecil
Occasional Contributor III

I’m on Pro 2.7, so Python 3.7.9

0 Kudos
DanPatterson
MVP Esteemed Contributor

its more the server side that I was wondering, not Pro

f = '%m/%d/%Y %H:%M%p'

nw = datetime.datetime.now()

nw.strftime(f)
'01/28/2021 19:19PM'

... sort of retired...
0 Kudos