Forum Discussion
How to prevent automatic datatype conversion with database connection
ChrisMajestic wrote:
I forgot to mention that I'm simply trying to get it to import as text. The underlying data is a duration
Then you have to add a step doing an explicit cast or conversion to text. Otherwise Power BI will attempt to use the closest compatible data type.
I tried that but converting it to text doesn't revert the numbers back what they were prior to the transformation. In other words the previous number was 20:21:34 which it converted to 8:21:34 pm. So when I try to convert it to text it keeps it as 8:21:34 pm in text form instead of 20:21:34.
- d_gosbell2 years agoSuper User
So this could also be an issue with type conversion in the ODBC driver. You could try doing the conversion to a string explcitly in a view or SQL query so that it's done by the source database engine.
- ChrisMajestic2 years agoFrequent Visitor
Sounds interesting. How do I do that?
- d_gosbell2 years agoSuper User
It depends on what sort of database server you are pulling the data from. In SQL Server you could use the CONVERT() function with the optional 3rd parameter to specify the format. The DBA for your source database might be able to help with this.