Select to view content in your preferred language

Fastest way to convert date and time data to a different timezone from UTC

165
2
2 weeks ago
Bailey_Briggs
Emerging Contributor

I need help converting the dates/times of ~130k records from UTC (Survey123 standard) to a local time zone. I can't seem to find any good answers that don't take forever and/or freeze Pro. 

What I've tried: 

Convert time zone:  Takes hours, had to stop at hour 4 to do other work.

Calculate field: !date_! - (datetime.timedelta(hours=6)) : Got a type error: unsupported operand type(s) for -: 'str' and 'datetime.timedelta' 

Exported the data with the correct time zone applied in the Environments settings: Also takes hours and bricks Pro. 

Am I missing something? The AGOL layer shows the correct time zone, but I don't know how to export it into Pro without it defaulting to UTC. This feels very basic, so I don't know why I'm struggling with it. Any advice is appreciated!

0 Kudos
2 Replies
Bailey_Briggs
Emerging Contributor

Figured it out kind of. Needed to export the data then convert time zone. I guess trying to convert time zone on the hosted feature layer was what was causing the hold up. 

CalvinHarmin
Frequent Contributor

This may not be relevant to your use case but here's my experiences:

In the case of query using ArcGIS REST API and doing something with the response and for updating the values, you can use SQL-friendly time operations.

In the case of Survey123 and Power Automate, it receives the datetime from AGOL hosted feature layer date fields as UNIX Epoch time, or I think it's also referred to as an 'epoch milliseconds' integer. It's a weird thing that references 1970 as the starting point in time and counts up in milliseconds from there. I assume this is the 'real' value stored in AGO databases, and ArcGIS Pro is just interpreting that at either UTC, or showing it as local time zone if ArcGIS Pro settings are configured for that.

I recall some confusion about if this local time zone is something you can actually configure or not so I'm not sure about that. It might automatically display UTC times as local times in Pro.

Have you already perused this documentation page? It might give you some more information about date/time issues. There is a newer field type called TimestampOffset which may be useful if you want to retain original UTC times.

https://pro.arcgis.com/en/pro-app/latest/help/data/tables/date-fields.htm

https://doc.arcgis.com/en/arcgis-online/manage-data/work-with-date-fields.htm 

P.S. Converting epoch milliseconds to EST string date time in Power Automate is really fun:

convertTimeZone(
  addSeconds('1970-1-1'
    div(<source AGO datetime>,1000),
    'MM/dd/yyyy hh:mm:ss tt'
   ),
  'UTC','Eastern Standard Time',
  'MM/dd/yyyy hh:mm:ss tt'
)