Page 1 of 1

Dateformat for ZQuery.Params

Posted: 11.03.2021, 14:47
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

Re: Dateformat for ZQuery.Params

Posted: 12.03.2021, 09:57
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

Re: Dateformat for ZQuery.Params

Posted: 13.03.2021, 16:31
by nlanger
oh yes the properties on the Zconn :v:
sometimes you need food for thought :D

OK, thanks

Norbert