Good afternoon
I am trying to read this field that stores a date. It prints as an integer, I cannot convert it to a date.
Please advise
with arcpy.da.SearchCursor(feature_class, ["*"],where_clause ) as cursor:
for row in cursor:
row_value = row[cursor.fields.index("LAST_UPDAT")]
rowdate_only = row_value.date() -- This fails
Please make use of code sample formatting for Python code to avoid indent ambiguity, like so:
with arcpy.da.SearchCursor(feature_class, ["*"], where_clause) as cursor:
for row in cursor:
row_value = row[cursor.fields.index("LAST_UPDAT")]
rowdate_only = row_value.date() # This fails
What's the data type of "LAST_UPDAT"? If it's a string you'll need to use the this method, if it's an integer that represents a UNIX timestamp try something in this StackOverflow thread, and if it's a custom integer representation then parsing is non-trivial.
Good morning @DavidSolari
Environment:
Field Name: USERID, Field Type: Integer
Field Name: LAST_UPDAT, Field Type: Date, with value 1/31/2023 4:58:00.000 PM
SDE database in Ms SQS Server
Workstation and servers running in Windows
I am reading records from an SDE layer located in a Ms SQL Server database, and my goal is to update the same record on a AGOL hosted feature. I am reading all records from SDE using arcpy.da.SearchCursor, then searching using USERID field in the hosted feature and comparing dates using LAST_UPDAT field.
The compare dates does not work, something is missing.
My questions:
Thanks
Unfortunately, dates in cursors are handled differently between ArcGIS Desktop/ArcMap and ArcGIS Pro, so which software you are using makes a difference. Which one are you using?