UTC Time Format from API call

Copper Contributor

I have configured a source in Power Query Editor to import data in which the times are in UTC milliseconds. See sample below.

catremor_0-1605128702401.png

This results in Power Query converting this to scientific notation. See sample below.

catremor_1-1605128906285.png

I have attempted creating a Custom Column using various formulas that I have found but they have only resulted in 'Error' messages. 

 

Is there a way to prevent this conversion to scientific notation during import? Or, once imported, a formula that can be used to convert this to a readable date format?

1 Reply

@catremor 

To convert from Unix time, which is number of milliseconds (in your case , could be seconds) from start of 01 Jan 1700 UTC

image.png

to common one

image.png

you may use something like

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    ReplaceStart = Table.ReplaceValue(
        Source,
        each [Start],
        each #datetime(1970, 1, 1, 0, 0, 0) + #duration(0, 0, 0, [Start]/1000),
        Replacer.ReplaceValue,{"Start"}
    ),
    ReplaceEnd = Table.ReplaceValue(
        ReplaceStart,
        each [End],
        each #datetime(1970, 1, 1, 0, 0, 0) + #duration(0, 0, 0, [End]/1000),
        Replacer.ReplaceValue,{"End"}
    )

in
    ReplaceEnd

 To adjust time zone use second parameter in #duration(), e.g. -3 for UTC-3