Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Alkhos
Advocate I
Advocate I

DataFormat.Error: We couldn't parse the input provided as a DateTime value.

Hello,

 

I am working with a dataset retrieved as a CSV file through web.

I have a time field on the dataset with values similar to below:

         10/31/2016 4:05:00 PM

 

When data is fed to PBI desktop, it is automatically detected as "text".

When I attempt to change its type to Date/Time, I get the following error:

 

       DataFormat.Error: We couldn't parse the input provided as a DateTime value.
       Details:
       10/31/2016 6:25:00 PM

 

I have checked the source, all values are similarly formatted ( no add values in the time field )

I have also used PromoteHeaders to prmote the first row ( which contains header to the header field ) before trying to change the type.

 

The exact step that fails uses this DAX code:

 

         #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"time", type datetime}}),

 

Is there anything that I am doing wrong? or do I need any further pre-processing on this time field to be able to properly parse it?

 

Thanks

Ali

 

1 ACCEPTED SOLUTION

After playing with your text file for 15 mins, I have found that there are some extra space at the front of your date column. Can you please remove those extra characters. 

 

Steps to follow afterwards:

1. Split the column by 11 characters. This will separate Date and Time

2. Split the Date column by "/" Delimiter

3. Change the data type of the newly created columns to Whole number

4. Bring the Day column first by dragging, Month column second and Year column last

5. Select all these three collumns and go to Add column Tab, Select Merge Columns and in Merge dialog, Select "/"Separator.

6. Change the data type of the merged column to Date.

 

So many steps .....

 

 

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

View solution in original post

32 REPLIES 32
Belin
Frequent Visitor

If the problem are the leading spaces, as mentioned by @BhaveshPatel , then you need to right click in the column and select transform>trim

 

https://radacad.com/trim-vs-clean-in-power-bi-and-power-query#:~:text=Trim%20is%20a%20very%20commonl....

 

If this works better please remeber to mark it, so others will benefit

MyroslavaM
Advocate II
Advocate II

You can specify the default format of receiving the data for Date format.
Just add en-GB or en-US in the end in the M code.
it prevents from failing the convertation 🙂
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"Date", type date}}, "en-GB")

Anonymous
Not applicable

Hi, the power query editor considers your laptop's default date format so if the data is not in that format it might cause a problem in changing the data type. 
Hence, you may split the column by delimiter and add a new column (using add a column from example, considering your system's date format).

danielukasoanya
New Member

I had same error, solution was to check source file and I noticed the bottom cells of the date column was merged and had other data that wasnt dates and could not be formatted as date. Solution was to delete these rows and refresh Power Query and it worked

maples_90
New Member

I faced the same issue. I went back & checked my data sets, I noticed that the date columns were different in 2 of the 6 files. 

One needs to double check the data source which is being appended. 

data parse is however a more elegant and practical solution as not all the data sources can be manipulated and after a while you may decide to change data source.

Also there is always the problem that if you or anyone else forgot to check the file loaded, the error will reappear...but if you parse, no matter what you always get eh same result...

Think holistically and prepare for the worst 🙂

Belin
Frequent Visitor

In Power Query, go to transform in the ribbon and then Date>Parse

Belin_0-1667956432453.png

 

Raj007
Helper III
Helper III

DataFormat.Error: We couldn't parse the input provided as a Date value.
Details:
7/18/1996

vaniprasanna
Frequent Visitor

Thanks. I could resolve the issue. The solution worked.

IWasTheL10N
New Member

Just a Note:  I had the same error when I tried to format and American Date (MMDDYY).  If you're in Europe (Ireland anyway) you need to arrange the date in DD/MM/YY.  

RaviTeja_M
Advocate I
Advocate I

Steps to be followed  to resolve the Date Format Error :

 

1. When  a CSV file is loaded in Power BI Desktop  by default it detects the 'date/time' field  as 'text' so when we try to convert we get an error.

 

Date_Format_Error.png

 

2. Next Right click on the Field/Column  you want to convert into a Date Field and navigate to 'Change Type' .

 

Change_type.png

 

3. Next Click on 'Using Locale' option under the 'Change Type' dropdown.

 

Using_locale.png

 

4. Change the 'Data type' to 'Date' in the dialog box of 'Using Locale'  as by default it takes it as 'text'.

 

date_as_datatype.png

5. Click on the drop down of 'locale'.

 

Locale_Drop_down.png

6. Then Select an 'Option' from drop down for which your Date field  'Format' matches exactly and Click on 'OK' . 

 

Format.png

7. Above steps will resolve the issue and same solution goes well for Date/Time column conversion also.

 

This is awesome detailed solution!

Thank you! 

These steps were really helpful. thanks

@RaviTeja_M this helped me solve the problem thank you.

Thank you! This solution worked for me 😀

this solution worked for me, thanks a lot for sharing your knowledge

Superb! Works perfectly

@RaviTeja_M your hint solved my issue, thak you!

kingrob01
Frequent Visitor

How would I fix this error? It appears after I perform a data refresh.

DataFormat.Error: We couldn't parse the input provided as a DateTime value.
Details:
18 Days 15 Hours 59 Minutes

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.