Forum Discussion

deannag's avatar
deannag
Icon for Helper I rankHelper I
3 years ago

How can I change time zone from UTC to a specific time zone?

Hi, 

 

I have a series of Event Dates with times and Invoice Dates with times. In power query, I split by the delimiter (T) to get separate columns for dates and times. The Event Date/time is automatically in the local time of the venue, but the invoice date/time is automatically in UTC and I would like to change that to be in the same time zone as the venue of the event. 

 

I saw that there's DateTimeZone.LocalNow, but I don't want it in my local time zone. I've had the time zone in the same column as the date, and I've also been able to strip the time zone from the time column and keep it in a separate column. Would love any input on the best way to do this. 

 

Subtracting hours from the time is not an option because of daylight savings, and I need to be more granular than that.

 

I found this webpage: https://learn.microsoft.com/en-us/powerquery-m/datetimezone-functions but I still need some help on how to use it. 

5 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Icon for Most Valuable Professional rankMost Valuable Professional

    As per your description, Invoice Date Time is already in UTC. Let's say you want to offset it by +0730 as per your required timezone

    = DateTimeZone.SwitchZone(DateTime.AddZone([Invoice Date Time], 0), 7, 30)

    If Invoice Date Time is already in time zone format, then 

    = DateTimeZone.SwitchZone([Invoice Date Time], 7, 30)