Page 1 of 1

Shouldn't the SQLConnection's DatetimeReadFormat affect TZFormatSettings...?

Posted: 01.09.2021, 14:41
by aehimself
Hello,

I have a connection, where I set the DatetimeReadFormat property to yyyy.mm.dd hh:nn:ss. Displaying the information in a DBGrid works just fine.
However, when I copy the data with ClipBoard.AsText := Self.SelectedField.AsString; this format is omitted and resets to TZFormatSettings and results something like "2018/ 12/ 12/ 0:00:00".

So, the question is, shouldn't DatetimeReadFormat affect the format settings inside a TZConnection...?

If yes, an important note to add is that these properties are NOT set design-time but runtime, before calling .Connect.

Re: Shouldn't the SQLConnection's DatetimeReadFormat affect TZFormatSettings...?

Posted: 01.09.2021, 15:50
by marsupilami
Hello aehimself,

I am not sure, if I understand you correctly. DatetimeReadFormat is meant for situations where we read dates and time from the database as Strings. So it tells us how the database formats its DateTime values. It shouldn't do anything on TZFormatSettings because they are used for displaying dates and times to the user only - at least as far as I know. This is what the documentation has to day about this:
Zeos 7.2 Release Notes wrote: The ReadFormat parameters decribe the date and time formats as the database sends them to the application.
[...]
These settings can be used to solve problems on the following drivers:
  • dblib (FreeTDS, mssql, sybase)
  • postgresql
  • mysql (depending on parameter preferprepared, used if preferprepared is not set)
  • ado (emulated parameters [...])
We don't use these params on PostgreSQL anymore because there we use binary representations now.

Best regards,

Jan

Re: Shouldn't the SQLConnection's DatetimeReadFormat affect TZFormatSettings...?

Posted: 01.09.2021, 16:45
by aehimself
Ooooooooooh that makes sense.

So the answer is: absolutely NOT :)

Thanks for clearing this up so quickly!