Select to view content in your preferred language

Copy data with Python from AGOL to ENTERPRISE without changing time zone of date fields

411
2
07-20-2022 06:44 AM
NicolasDELAVAL
New Contributor II

Hi,

I would like to copy data hosted in an AGOL layer to a map service hosted layer in my Enterprise Portal. The structures of these 2 layers are identical.

This data includes a date field which is stored in AGOL in UTC.

From ArcGIS Pro, I shared the destination layer as a web layer to my Enterprise Portal. So an ArcGIS Server service was published. In the parameters of this ArcGis Server service, date field parameter is set to UTC time zone.

However when I use the python function "featurelayer.edit_features(adds)" to copy my data from AGOL to the PORTAL, on arrival my date fields have been converted to local time (UTC - 2).

Whatever the place from which I query them (from the Portal directly or from ArcGis Pro or even from a Python script), the values ​​of my date fields have lost 2 hours.

I ask for your help to understand how to succeed in copying my data while keeping them in UTC.

Thanks for your help

0 Kudos
2 Replies
EmmaHatcher
Occasional Contributor

I am also struggling with this issue. At the moment, my solution is after new features are added, use an update cursor on the date fields to convert them using pytz, tzinfo. You can also use the datetime package timedelta module in the update cursor. Not ideal, since it requires editing to be enabled on the Portal item, but so it is...

0 Kudos
NicolasDELAVAL
New Contributor II

Hello EmmaHatcher,

Thanks for sharing your experience. Indeed, the solution you propose solves the problem. However, I still do not understand where this time zone adjustment comes from when it is not requested. I contacted ESRI support who don't understand either... A date type data should normally be copied by the Python function in UTC without modification.

0 Kudos