Handling British Summer time when querying SharePoint from Power Automate

This also applies to other TimeZones.

When you query SharePoint in Power Automate using steps like "Get Items" the raw information that is returned when you are working with dates and currently inside British Summer Time will be out by an hour.

Below I've created a step which runs Get Items and I add a compose to check the Created date:


Going into SharePoint you can see the date time returned is an hour out (I'm currently inside British Summer Time and my laptops date/time is set as such).


Whenever you are handling dates from SharePoint in Power Automate you have to remember that the original value stored in SharePoint for date/time is the UTC value. Depending on your regional settings the value is converted for you when it's rendered.

Fear not! Power Automate has conversions, here's one way:


In the example above I'm taking the source Created date/time which is in UTC and converting it to my location - Dublin, Edinburgh, Lisbon, London. The expected Created time is returned:


Another method (as more of a one liner) which you can use when setting a field is included below.
Note: ("items('Apply_to_each)'?['Created'] is the Created date/time from SharePoint):

convertTimeZone( items('Apply_to_each')?['Created'] ,'GMT Standard Time', 'UTC','yyyy-MM-ddTHH:mm:ss')



This also counts when you are querying SharePoint date/time fields! So definitely store a converted date in UTC format if you are then using it in "Get Items" with an odata query. 

E.g. if you make up your own specific time like 25/06/2023 @ 15:00BST you'll want to convert this to UTC first by doing the opposite of the above.

Hope it helps!

Comments

Popular posts from this blog

Use Power Automate to create a Document Set – The easy way!

Power Automate - Get SharePoint items using Created By/Modified By