Get Free Trial

Invalid datetime data formatting in CSV data source connected to a PostgreSQL database with .NET

Alex asked on February 2, 2021

There is an issue with CSV data source connected to a PostgreSQL database with .NET.

After upgrading the Npgsql package from 4.1.8 to 5.0.3 the data for datetime columns are returned in invalid format.
Before package upgrade the data was looking like this:
After upgrading the data formatting is broken
“1/29/2021 5:41:32 PM”,”00:01:00″
“2/2/2021 12:12:19 PM”,”00:45:00″

Data retrieved from database with code:

// ....
using (IDataReader dataReader = await command.ExecuteReaderAsync())
using (Stream inputStream = Compressor.Compressor.CompressDb((DbDataReader)dataReader))
using (StreamReader streamReader = new StreamReader(inputStream))
return await streamReader.ReadToEndAsync();

How the issue can be solved?

Thanks for your help.

1 answer

Illia Yatsyshyn Illia Yatsyshyn Flexmonster February 3, 2021

Thank you for reaching out to us.
We would like to explain that the Data Compressor does not affect the way the Npgsql driver returns the data from your database.
Flexmonster Data Compressor only receives this data and passes it to the client-side component in CSV format.
Therefore, we suggest either adjusting the Npgsql configuration so that it returns dates in the required format or downgrading back to the 4.1.8 version of the Npgsql driver.
We hope it helps.
Please contact us in case other questions arise.

Please login or Register to Submit Answer