0

I'm importing a csv data file into power bi power query. One of the columns has dates. 90% of the records are formatted as mm/dd/yyyy hh:mm:ss pm/am (12/7/2022 12:30:01 PM). The other 10% of the records are formatted as mm/dd/yyyy hh:mm:ss:mmm (12/7/2022 12:30:01:443). Therefore, the records with the milliseconds show as an error.

I tried to split the records, I tried to change the Locale and i tried to change the data type. The millisecond records are still showing as errors. I want the millisecond records to show the entire value so that I can split all records and then receive just the date.

0

1 Answer 1

0

Add column .. custom column ... with

= try DateTime.FromText([Column1], [Format="MM/dd/yyyy hh:mm:ss tt"]) otherwise DateTime.FromText([Column1], [Format="MM/dd/yyyy HH:mm:ss:fff"])

use the real name of your column in place of [Column1]

replace the last ) at the end of the formula with ,type datetime)

sample:

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "Custom", each try DateTime.FromText([Column1], [Format="MM/dd/yyyy hh:mm:ss tt"]) otherwise DateTime.FromText([Column1], [Format="MM/dd/yyyy HH:mm:ss:fff"]), type datetime)
in #"Added Custom"

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.