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
michellepace
Resolver III
Resolver III

Connection Error - how to elegantly handle dirty dates in a DATE column?

Hello,

I am connecting to a Pervasive SQL database. When trying to connect to the SupplierMaster table I am getting the below date/time error in PowerBi. This is due to the "dirty" value I have in the LastCrDate date column, namely "11/30/0011".

Question: What is the most elegant way to handle this "dirty date" scenario? (I'm not permitted to "fix" any values in the database)

 

Error & Raw Data.png

Thanks in advance, Michelle

1 ACCEPTED SOLUTION

Hi @ImkeF .
>can you copy and paste the code that has been generated for this query? 
It cannot be the code because once I fix the data in the datacase, everything works as it such. Thus ruling out the code. Nonethless, so you can see here it is: = Odbc.Query("dsn=PastelDB.odbc", "select LastCrDate from SupplierMaster")

 

Hi @v-eachen-msft ,
> Try to add a sql query with FORMAT() and import data as text.
Thank-you, this is a perfect answer!  I changed my query to = Odbc.Query("dsn=PastelDB.odbc", "select convert(LastCrDate,SQL_VARCHAR) from SupplierMaster") . It works like a charm. Now I can handle what to do with dirty dates within Power Bi (eg convert a dirty date to 01/01/1970). I'll defintely use this in future scenarios where I cannot change the db. 

 

My Final Solution: The database owner gave me permission to "fix" dirty date values in his PastelDb. So I fixed them all with this by running the below sql against the pervasive database. Power Bi works fine now with the orginal purple query above. 

 

 

update "SupplierMaster"
set LastCrDate = '1970-01-01'
WHERE LastCrDate not between '1970-01-01' and '2020-07-29'

 

Thank you both, I learnt something very useful in spite of the final solution.
Michelle

View solution in original post

5 REPLIES 5
v-eachen-msft
Community Support
Community Support

Hi @michellepace ,

 

Try to add a sql query with FORMAT() and import data as text. 

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Hi @ImkeF .
>can you copy and paste the code that has been generated for this query? 
It cannot be the code because once I fix the data in the datacase, everything works as it such. Thus ruling out the code. Nonethless, so you can see here it is: = Odbc.Query("dsn=PastelDB.odbc", "select LastCrDate from SupplierMaster")

 

Hi @v-eachen-msft ,
> Try to add a sql query with FORMAT() and import data as text.
Thank-you, this is a perfect answer!  I changed my query to = Odbc.Query("dsn=PastelDB.odbc", "select convert(LastCrDate,SQL_VARCHAR) from SupplierMaster") . It works like a charm. Now I can handle what to do with dirty dates within Power Bi (eg convert a dirty date to 01/01/1970). I'll defintely use this in future scenarios where I cannot change the db. 

 

My Final Solution: The database owner gave me permission to "fix" dirty date values in his PastelDb. So I fixed them all with this by running the below sql against the pervasive database. Power Bi works fine now with the orginal purple query above. 

 

 

update "SupplierMaster"
set LastCrDate = '1970-01-01'
WHERE LastCrDate not between '1970-01-01' and '2020-07-29'

 

Thank you both, I learnt something very useful in spite of the final solution.
Michelle

ImkeF
Super User
Super User

Hi @michellepace ,

try disabling the automatic type detection in the options:

 

image.png

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hi @ImkeF  thank you for your speedy reply and effort to make such an easily understantable screenshot. I tried as you suggested however I have the same error as originally posted. 🙁

Hi @michellepace ,

can you copy and paste the code that has been generated for this query? (Delete any private data of the actuals datasource, but keep all M-function in please)

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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!

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.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.