Forum Discussion

M_SBS_6's avatar
M_SBS_6
Helper V
2 years ago
Solved

Date Format

Hi, I'm importing a PDF into power bi but the date withing the PDF is formatted as 1/22/2024.    Within Power Query I tried to change to a Date but it errors:  DateFormat.error: we couldn't parse ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, M_SBS_6 


    According to your description, you have an error in converting the time format, according to my test, the format "1/22/2024" can be converted normally. You can try the following to solve the problem.
    1. Please check whether all the data formats of your date columns are unified.

    PDF:

    Test:

    2. If the format is uniform, you can modify the query in Power BI Advanced Editor to use the 'Date.FromText' function to specify the format of the date string. For example, if the date is formatted as 'M/dd/yyyyy' (e.g., '1/22/2024'), the following M code can be used:

    let
    Source = ... ,
    ConvertedDate = Table.TransformColumns(Source, {"YourDateColumnName", each Date.FromText(_, "en-US", "M/dd/yyyy"), type date})
    in
    ConvertedDate

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum