Hello friends
I am using the lazarus 0.9.12, zeoslib 6.5.1 and postgresql 8.1.2, when I type the date ' 16/02/2006 ' in the dbedit and when I execute the post it is recorded in the database 30/12/1899.
if I execute in a zquery or in the pgadmin (update table set last_date = ' 02/16/2006') the date is recorded correct, and when calling the program appears in the dbedit 30/12/1899.
Can anybody help? This is a bug of zeos?
thank you very much
Silvio Guedes
error update date field
Moderators: gto, cipto_kh, EgonHugeist
Hi,
This is a bug from Zeos components on the interface with PostgreSQL.
The matter is that Zeos components only parse Date formats like 1999-02-01 (i.e. ANSI SQL Date Format), but PosgreSQL can be configured to support the SQL style (your Date format I guess..), the German style,...
To resolve this bug you have to modify the function
"ZDbcPostgreSQLResultSet.pas" --> "GetDate" to process Date formats like ##/##/####
Regards.
This is a bug from Zeos components on the interface with PostgreSQL.
The matter is that Zeos components only parse Date formats like 1999-02-01 (i.e. ANSI SQL Date Format), but PosgreSQL can be configured to support the SQL style (your Date format I guess..), the German style,...
To resolve this bug you have to modify the function
"ZDbcPostgreSQLResultSet.pas" --> "GetDate" to process Date formats like ##/##/####
Regards.
-
- Junior Boarder
- Posts: 42
- Joined: 24.08.2005, 12:54
- Location: The Most Oriental Point of America - João Pessoa - Brazil
- Contact:
Hello DiegoBM
I made the modifications that it indicated I compiled myself and I installed zeoslib again, but the mistake continues. I type in the dbedit of the lazarus 22/02/2006 (format of date in the Brazilian) and when recording the registration the dbedit it shows 31/12/1899.
Respectfully
Silvio Guedes
I made the modifications that it indicated I compiled myself and I installed zeoslib again, but the mistake continues. I type in the dbedit of the lazarus 22/02/2006 (format of date in the Brazilian) and when recording the registration the dbedit it shows 31/12/1899.
Respectfully
Silvio Guedes
-
- Junior Boarder
- Posts: 42
- Joined: 24.08.2005, 12:54
- Location: The Most Oriental Point of America - João Pessoa - Brazil
- Contact:
This is the routine:
function TZPostgreSQLResultSet.GetDate(ColumnIndex: Integer): TDateTime;
var
Value: string;
begin
{$IFNDEF DISABLE_CHECKING}
CheckColumnConvertion(ColumnIndex, stDate);
{$ENDIF}
Value := GetRawString(ColumnIndex);
if IsMatch('????-??-??*', Value) then
Result := Trunc(AnsiSQLDateToDateTime(Value))
else Result := Trunc(MySQLTimestampToDateTime(Value));
end;
I should change this line
if IsMatch ('???? -?? -?? * ', Value) then
new line
if IsMatch ('##/##/####* ', Value) then
Thank you very much
Silvio Guedes
function TZPostgreSQLResultSet.GetDate(ColumnIndex: Integer): TDateTime;
var
Value: string;
begin
{$IFNDEF DISABLE_CHECKING}
CheckColumnConvertion(ColumnIndex, stDate);
{$ENDIF}
Value := GetRawString(ColumnIndex);
if IsMatch('????-??-??*', Value) then
Result := Trunc(AnsiSQLDateToDateTime(Value))
else Result := Trunc(MySQLTimestampToDateTime(Value));
end;
I should change this line
if IsMatch ('???? -?? -?? * ', Value) then
new line
if IsMatch ('##/##/####* ', Value) then
Thank you very much
Silvio Guedes
Well I use Delphi7, but I guess that's not the matter...
The problem is also on the "AnsiSQLDateToDateTime" and "MySQLTimestampToDateTime" conversion functions which are also Date-Format specific.
Here goes mine one (not perfect but it works ):
function TZPostgreSQLResultSet.GetDate(ColumnIndex: Integer): TDateTime;
var
Value: string;
begin
{$IFNDEF DISABLE_CHECKING}
CheckColumnConvertion(ColumnIndex, stDate);
{$ENDIF}
Value := GetString(ColumnIndex);
if IsMatch('????-??-??*', Value) then
Result := Trunc(AnsiSQLDateToDateTime(Value))
else if IsMatch('??/??/????', Value) then
begin
Result := StrToDateTime(Value);
end
else Result := Trunc(MySQLTimestampToDateTime(Value));
end;
Hope this can help you
Regards.
The problem is also on the "AnsiSQLDateToDateTime" and "MySQLTimestampToDateTime" conversion functions which are also Date-Format specific.
Here goes mine one (not perfect but it works ):
function TZPostgreSQLResultSet.GetDate(ColumnIndex: Integer): TDateTime;
var
Value: string;
begin
{$IFNDEF DISABLE_CHECKING}
CheckColumnConvertion(ColumnIndex, stDate);
{$ENDIF}
Value := GetString(ColumnIndex);
if IsMatch('????-??-??*', Value) then
Result := Trunc(AnsiSQLDateToDateTime(Value))
else if IsMatch('??/??/????', Value) then
begin
Result := StrToDateTime(Value);
end
else Result := Trunc(MySQLTimestampToDateTime(Value));
end;
Hope this can help you
Regards.