Dateformat for ZQuery.Params

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
nlanger
Junior Boarder
Junior Boarder
Posts: 27
Joined: 14.10.2020, 21:56

Dateformat for ZQuery.Params

Post by nlanger »

I would like to pass the date in the format DD.MM.YYYY as a parameter to ZQuery.
Where and how do I have to set the format for the date?

I've tried the source code ...

GetFormatSettings;
FormatSettings.ShortDateFormat:='dd.mm.yyyy';

... but in unit "ZSysUtils" in function
TryPCharToDate(P: PAnsiChar; Len: Cardinal; const FormatSettings: TZFormatSettings; var Date: TZDate): Boolean;

FormatSettings.DateFormat stayed at "YYYYMMDD"

OR

QU.SQL.Text:='set language "german"';
QU.ExecSql;

without effect :-(

Norbert
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 765
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Dateformat for ZQuery.Params

Post by aehimself »

Why not using .AsDateTime?

SQLQuery.SQL.Text := 'UPDATE mytable SET datefield = :pDateTime';
SQLQuery.ParamByName('pDateTime').AsDateTime := Now;
SQLQuery.ExecSQL;

Gets rid of all date conversion hassle.

Edit:
I think what you are looking for are parameters of the connection. Check ZPropertiesEditor.pas or set the parameters design time:

DateReadFormat, DatetimeReadFormat, DatetimeWriteFormat, DateWriteFormat, TimeReadFormat, TimeWriteFormat
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
nlanger
Junior Boarder
Junior Boarder
Posts: 27
Joined: 14.10.2020, 21:56

Re: Dateformat for ZQuery.Params

Post by nlanger »

oh yes the properties on the Zconn :v:
sometimes you need food for thought :D

OK, thanks

Norbert
Post Reply