Subject | Re: Problem with TIMESTAMP field precision |
---|---|
Author | alexanderl3 |
Post date | 2005-08-18T10:00:24Z |
IBSQL.PAS
This is in IBX5. Make sure you have the latest version. Commented
out lines are those that were there before.
const
IBTimeDivider=24*60*60*10000;
IBDateOffset=-15018;
procedure TIBXSQLVAR.SetAsDateTime(Value: TDateTime);
var
i: Integer;
tm_date: TCTimeStructure;
Yr, Mn, Dy, Hr, Mt, S, Ms: Word;
xvar: TIBXSQLVAR;
begin
if IsNullable then
IsNull := False;
for i := 0 to FParent.FCount - 1 do
if FParent.FNames[i] = FName then
begin
xvar := FParent[i];
xvar.FXSQLVAR^.sqltype := SQL_TIMESTAMP or
(xvar.FXSQLVAR^.sqltype and 1);
// 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);
// IBAlloc(xvar.FXSQLVAR^.sqldata, 0,
xvar.FXSQLVAR^.sqllen);
// isc_encode_date(@tm_date, PISC_QUAD
(xvar.FXSQLVAR^.sqldata));
xvar.FXSQLVAR^.sqllen := SizeOf(TISC_TIMESTAMP);
IBAlloc(xvar.FXSQLVAR^.sqldata, 0, xvar.FXSQLVAR^.sqllen);
With PISC_TIMESTAMP(xvar.FXSQLVAR^.sqldata)^ do
begin
timestamp_date := Trunc(Value)-IBDateOffset;
timestamp_time := Round(IBTimeDivider*Abs(Frac(Value)));
end;
xvar.FModified := True;
end;
end;
--- In firebird-support@yahoogroups.com, "ibrahim bulut"
<i.bulut@i...> wrote:
This is in IBX5. Make sure you have the latest version. Commented
out lines are those that were there before.
const
IBTimeDivider=24*60*60*10000;
IBDateOffset=-15018;
procedure TIBXSQLVAR.SetAsDateTime(Value: TDateTime);
var
i: Integer;
tm_date: TCTimeStructure;
Yr, Mn, Dy, Hr, Mt, S, Ms: Word;
xvar: TIBXSQLVAR;
begin
if IsNullable then
IsNull := False;
for i := 0 to FParent.FCount - 1 do
if FParent.FNames[i] = FName then
begin
xvar := FParent[i];
xvar.FXSQLVAR^.sqltype := SQL_TIMESTAMP or
(xvar.FXSQLVAR^.sqltype and 1);
// 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);
// IBAlloc(xvar.FXSQLVAR^.sqldata, 0,
xvar.FXSQLVAR^.sqllen);
// isc_encode_date(@tm_date, PISC_QUAD
(xvar.FXSQLVAR^.sqldata));
xvar.FXSQLVAR^.sqllen := SizeOf(TISC_TIMESTAMP);
IBAlloc(xvar.FXSQLVAR^.sqldata, 0, xvar.FXSQLVAR^.sqllen);
With PISC_TIMESTAMP(xvar.FXSQLVAR^.sqldata)^ do
begin
timestamp_date := Trunc(Value)-IBDateOffset;
timestamp_time := Round(IBTimeDivider*Abs(Frac(Value)));
end;
xvar.FModified := True;
end;
end;
--- In firebird-support@yahoogroups.com, "ibrahim bulut"
<i.bulut@i...> wrote:
> i have a questionprecision
> which unit of IBX you changed with this code
>
>
>
> ----- Original Message -----
> From: "alexanderl3" <alexanderl@o...>
> To: <firebird-support@yahoogroups.com>
> Sent: Thursday, August 18, 2005 2:33 AM
> Subject: [firebird-support] Re: Problem with TIMESTAMP field
>(isc_encode_timestamp
>
> > Thanks a lot. It works fine now.
> >
> >
> > --- In firebird-support@yahoogroups.com, "Dmitry Sibiryakov"
> > <SD@t...> wrote:
> >> On 17 Aug 2005 at 1:01, alexanderl3 wrote:
> >>
> >> >Is it a bug or I need to change some settings to allow higher
> >> >resolution? Is it in IBX5, API DLL or FB itself?
> >>
> >> This is a bug. From my POV it is in IB API
> > ())with
> >> and IBX (that use this function).
> >>
> >> >If it is IBX5 problem, what other controls can be used to work
> >> >miliseconds?
> >>
> >> Hands.drv and Brain.sys.
> >>
> >> const
> >> IBTimeDivider=24*60*60*10000;
> >> IBDateOffset=-15018;
> >>
> >>
> >> Field.AsDateTime := Date; // Initialize buffer
> >> With PISC_TIMESTAMP(Field.Data^.sqldata)^ do
> >> begin
> >> timestamp_date := Trunc(Value)-IBDateOffset;
> >> timestamp_time := Round(IBTimeDivider*Abs(Frac(Value)));
> >> end;
> >>
> >> --
> >> SY, Dimitry Sibiryakov.
> >
> >
> >
> >
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Visit http://firebird.sourceforge.net and click the Resources item
> > on the main (top) menu. Try Knowledgebase and FAQ links !
> >
> > Also search the knowledgebases at http://www.ibphoenix.com
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> > __________ NOD32 1.1196 (20050817) Information __________
> >
> > This message was checked by NOD32 antivirus system.
> > http://www.eset.com
> >
> >