Forum Discussion

SylviaManzini's avatar
SylviaManzini
Regular Visitor
2 years ago

Change the time un more columns

I have a table with many date and time fields that takes data from a server with a time difference of 2 hours with my location. That means that if something happens on 09/12/2023 at 01:02 server time, I would need the data to be 09/11/2023 23:02, which is my local time because it changes the day of the event.
There are more than 20 date fields in the table and I think there may be a global solution that can be done from Power Query when I make the connection or program in M ​​and run it for all the columns. I look forward to suggestions

1 Reply

  • Hello, SylviaManzini 

    let
        Source = your_table,
        minus_two_hours = (x) => x + #duration(0, -2, 0, 0),
        // replace column names with yours in the list below
        columns = {"dt", "ddt"},
        transformations = List.Transform(columns, (x) => {x} & {minus_two_hours}),
        z = Table.TransformColumns(Source, transformations)    
    in
        z