Subject | Re: isc_encode_timestamp and milliseconds |
---|---|
Author | lintao_nz |
Post date | 2009-02-13T06:19:40Z |
Hi Dimitry,
I have found the solution by follow the instruction of follow link:
http://www.ibphoenix.com/main.nfs?a=ibphoenix&s=1154534295:6&page=ibp_60_sql_date_ds
==============================================
The existing V5 API calls isc_encode_date() and isc_decode_date() are
preserved, and function identically to isc_encode_timestamp() &
isc_decode_timestamp().
NOTE: None of the time / timestamp functions handle fractions of a
second as the OS tm structure has no field for fractional seconds. A
client can decode the fractional part by doing
seconds_fraction=iscTime % 10000;
seconds_fraction=iscTimestamp.time_part % 10000;
Encoding is done as:
iscTime +=(seconds_fraction % 10000);
iscTimestamp.time_part +=(seconds_fraction % 10000);
==============================================
So in my Delphi code, I do follow:
==============================================
DecodeDate(Value, Yr, Mn, Dy);
DecodeTime(Value, Hr, Mt, S, Ms);
with tm_date do begin
tm_sec := S;
tm_min := Mt;
tm_hour := Hr;
tm_mday := Dy;
tm_mon := Mn - 1;
tm_year := Yr - 1900;
end;
xvar.FXSQLVAR.sqllen := SizeOf(TISC_QUAD);
xvar.FXSQLVAR.SetDataSize(0, xvar.FXSQLVAR.sqllen);
FGDSLibrary.isc_encode_date(@tm_date,
PISC_QUAD(xvar.FXSQLVAR.sqldata));
if Ms > 0 then
begin
x_timestamp := DateTimeToTimeStamp(Value);
PISC_QUAD(xvar.FXSQLVAR.sqldata).gds_quad_low :=
x_timestamp.Time *10;;
end;
====================================================
It solves my problem.
Cheers,
Tao
--- In firebird-support@yahoogroups.com, Dimitry Sibiryakov <sd@...>
wrote:
I have found the solution by follow the instruction of follow link:
http://www.ibphoenix.com/main.nfs?a=ibphoenix&s=1154534295:6&page=ibp_60_sql_date_ds
==============================================
The existing V5 API calls isc_encode_date() and isc_decode_date() are
preserved, and function identically to isc_encode_timestamp() &
isc_decode_timestamp().
NOTE: None of the time / timestamp functions handle fractions of a
second as the OS tm structure has no field for fractional seconds. A
client can decode the fractional part by doing
seconds_fraction=iscTime % 10000;
seconds_fraction=iscTimestamp.time_part % 10000;
Encoding is done as:
iscTime +=(seconds_fraction % 10000);
iscTimestamp.time_part +=(seconds_fraction % 10000);
==============================================
So in my Delphi code, I do follow:
==============================================
DecodeDate(Value, Yr, Mn, Dy);
DecodeTime(Value, Hr, Mt, S, Ms);
with tm_date do begin
tm_sec := S;
tm_min := Mt;
tm_hour := Hr;
tm_mday := Dy;
tm_mon := Mn - 1;
tm_year := Yr - 1900;
end;
xvar.FXSQLVAR.sqllen := SizeOf(TISC_QUAD);
xvar.FXSQLVAR.SetDataSize(0, xvar.FXSQLVAR.sqllen);
FGDSLibrary.isc_encode_date(@tm_date,
PISC_QUAD(xvar.FXSQLVAR.sqldata));
if Ms > 0 then
begin
x_timestamp := DateTimeToTimeStamp(Value);
PISC_QUAD(xvar.FXSQLVAR.sqldata).gds_quad_low :=
x_timestamp.Time *10;;
end;
====================================================
It solves my problem.
Cheers,
Tao
--- In firebird-support@yahoogroups.com, Dimitry Sibiryakov <sd@...>
wrote:
>
> > Any suggestion?
>
> Don't use isc_encode_timestamp, work with TISC_TIME directly.
>
> SY, SD.
>