1

I have a column in a Power BI dataset which is Datetime values but in a String format. I've attempted to change the format to Date and Datetime but always receive the following error:

DataFormat.Error: We couldn't parse the input provided as a Date value. Details: 27MAY2021:15:42:29

All of the values in the column are as the format above, e.g. 04JAN2022:15:33:42 I want to convert all of the values in this column to Date or Datetime, but ideally 01/01/2022

1 Answer 1

2

Use this M-code to convert

let
    Source = Table.FromList({"27MAY2021:15:42:29", "04JAN2022:15:33:42"}, null, {"Date String"}),
    #"Changed Type" = Table.TransformColumnTypes(
        Source,{{"Date String", type text}}),
    #"Added Custom" = Table.AddColumn(
        #"Changed Type", "Date", 
        each DateTime.FromText([Date String], [Format="ddMMMyyyy:HH:mm:ss", Culture="en-US"]), type datetime)
in
    #"Added Custom"

enter image description here

Note that how the datetime is shown in your GUI depends on your regional settings.

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

1 Comment

I like your answer better.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.