I have some data in a file geodatabase feature class including some date fields. The precision on the date fields is to milliseconds and this is important.
When I copythe feature class from the fGDB to an SDE enterprise geodatabase (MS SQL Server 2014), the date precision appears to have some odd rounding applied to it.
Here's what the difference looks like:
>>> with arcpy.da.SearchCursor("Form_1_fGDB", ['EditDate']) as rows:
for row in rows:
print row[0]
2018-12-03 21:22:57.565000
2018-12-03 21:24:59.411000
2018-12-03 21:29:24.494000
2018-12-03 21:32:23.298001
2018-12-03 21:36:04.656000
2018-12-03 21:42:11.316000
2018-12-03 21:47:45.409001
2018-12-06 23:40:23.387000
2018-12-06 22:54:35.083000
>>> with arcpy.da.SearchCursor("Form_1_SDE", ['EditDate']) as rows:
for row in rows:
print row[0]
2018-12-03 21:22:58.000001
2018-12-03 21:24:59.000001
2018-12-03 21:29:24
2018-12-03 21:32:23
2018-12-03 21:36:05
2018-12-03 21:42:11
2018-12-03 21:47:45
2018-12-06 23:40:23
2018-12-06 22:54:35.000001
>>>
It looks like they are either rounded DOWN to the nearest whole second, or rounded UP to the whole second plus 1 millisecond.
I get the same result whether using:
- right-click and copy/paste in the catalog pane
- arcpy.FeatureClassToFeatureClass_management()
- arcpy.Append_management()
Why is this happening, and how can I preserve date value precision when copying data from an fGDB into an SDE GDB?
struct tm
, which stores seconds using an integer. The decimal values you're seeing are due to floating point representation issues.