ArcPy under ArcGIS Pro 2.3.2.
I am adding a Python datetime.datetime object to a shapefile attribute table using an arcpy insert cursor. The problem is that when I add the datetime instance, the date is preserved in the attribute table, but the time is set to 0:00.
Here is how I create the field:
arcpy.AddField_management(outfile_points, field_name='timestamp', field_type='DATE', field_is_nullable='NON_NULLABLE')
Here is how I add the data:
with arcpy.da.InsertCursor(outfile_points, field_list) as cursor: for a_storm in history.all_storms.values(): for a_rec in a_storm.record_dict.values(): data_list = [None] * len(field_list) data_list[field_dict[designation]] = a_storm.designation data_list[field_dict[timestamp]] = a_rec.record_time <=== # Eliding irrelevant code cursor.insertRow(data_list)
The line with <==== is where I assign the value. Note, the type of .record_time is datetime.datetime.
When I check the value of data_list in this module as it runs, the time of day is preserved in the list. But when I view the data from ArcGIS Pro, the time of day is reset to 0:00.
Can anyone recommend what I should do differently at the <=== line?
The whole module is at CreateHurricanePolylines.py