Board index » delphi » date FIELD type

date FIELD type

I have an IB6 database SQL dialect 3.
I have one field of type DATE
and another of type TIMESTAMP

I am trying to write a date / timestamp to these fields.
Cant seem to get my head around this

try
    myIBtable.transaction.startTransaction;
    myIBtable.edit();
    myIBtable.FieldByName('ON_DATE').As?????? := Date();
    myIBtable.FieldByName('ON_STAMP').AsDateTime:= Now();
    myIBtable.Post();
    myIBtable.transaction.commit;
except
    myIBtable.transaction.rollback;
end;

Any help would be appreciated.
Ron

 

Re:date FIELD type


AsDateTime.  IBX will truncate off the time portion before sending it on.
IBDataset and IBSQL both have an AsDate.  Note - D6 has a bug in its TimeStamp
handling due to a RTL change late in the game so you will have problems with the
D6 version only and TimeStamps.

Quote
Ron Craven wrote:

> I have an IB6 database SQL dialect 3.
> I have one field of type DATE
> and another of type TIMESTAMP

> I am trying to write a date / timestamp to these fields.
> Cant seem to get my head around this

> try
>     myIBtable.transaction.startTransaction;
>     myIBtable.edit();
>     myIBtable.FieldByName('ON_DATE').As?????? := Date();
>     myIBtable.FieldByName('ON_STAMP').AsDateTime:= Now();
>     myIBtable.Post();
>     myIBtable.transaction.commit;
> except
>     myIBtable.transaction.rollback;
> end;

> Any help would be appreciated.
> Ron

--
Jeff Overcash (TeamB)   I don't think there are any Russians
(Please do not email    And there ain't no Yanks
 me directly unless     Just corporate criminals
 asked.  Thank You)     Playing with tanks.  (Michael Been)

Re:date FIELD type


In article <3B4C68A5.E1605...@onramp.net>, overc...@onramp.net says...
Quote
> AsDateTime.  IBX will truncate off the time portion before sending it on.
> IBDataset and IBSQL both have an AsDate.  Note - D6 has a bug in its TimeStamp
> handling due to a RTL change late in the game so you will have problems with the
> D6 version only and TimeStamps.

I have had HUGE problems with TIME fields in Interbase 6 with D6.  My D5
app worked fine, but compiled with D6 (and the IBExpress that comes with
D6) I repeatedly get exceptions such as '0.25365478' is not a valid
timestamp.

Is there a workaround?

In the meantime, I have changed the fields in the database to have a
default value of 'NOW' and have removed the value setting from the SQL
just so I can continue working.  In the medium term, this is not
acceptable.

Any ideas for a short to medium term fix would be gratefully accepted.

Re:date FIELD type


Yes, change TIBCustomDataSet.SetInternalSQLParams to

            SQL_TYPE_TIME:
            begin
              ts.Date := 1;
              ts.Time := PInt(data)^;
              Qry.Params[i].AsTime :=
                TimeStampToDateTime(ts);
            end;

In all previous versions of Delphi TimeStampToDateTime would allow a Date of 0,
D6 it raises a conversion error.  Statically link in the change.

Quote
Trevor Jones wrote:

> In article <3B4C68A5.E1605...@onramp.net>, overc...@onramp.net says...
> > AsDateTime.  IBX will truncate off the time portion before sending it on.
> > IBDataset and IBSQL both have an AsDate.  Note - D6 has a bug in its TimeStamp
> > handling due to a RTL change late in the game so you will have problems with the
> > D6 version only and TimeStamps.
> I have had HUGE problems with TIME fields in Interbase 6 with D6.  My D5
> app worked fine, but compiled with D6 (and the IBExpress that comes with
> D6) I repeatedly get exceptions such as '0.25365478' is not a valid
> timestamp.

> Is there a workaround?

> In the meantime, I have changed the fields in the database to have a
> default value of 'NOW' and have removed the value setting from the SQL
> just so I can continue working.  In the medium term, this is not
> acceptable.

> Any ideas for a short to medium term fix would be gratefully accepted.

--
Jeff Overcash (TeamB)   I don't think there are any Russians
(Please do not email    And there ain't no Yanks
 me directly unless     Just corporate criminals
 asked.  Thank You)     Playing with tanks.  (Michael Been)

Re:date FIELD type


Quote
> Trevor Jones wrote:

 > Is there a workaround?

"Jeff Overcash (TeamB)" <overc...@onramp.net> wrote in message
news:3B56F727.E87E1611@onramp.net...

Quote
> Yes, change TIBCustomDataSet.SetInternalSQLParams to

>             SQL_TYPE_TIME:
>             begin
>               ts.Date := 1;
>               ts.Time := PInt(data)^;
>               Qry.Params[i].AsTime :=
>                 TimeStampToDateTime(ts);
>             end;

> In all previous versions of Delphi TimeStampToDateTime would allow a Date
of 0,
> D6 it raises a conversion error.  Statically link in the change.

Is there a workaround for dynamic linking?  My app is basically just a shell
which loads a package loader which....

At the moment, changing all the TIME fields in the database to TIMESTAMP
would be easier than statically linking.

I looks like I can't even subclass the TCustomDataset and everything which
depends on it because SetInternalSQLParams is private and is called by
various other private methods (probably a good thing, but certainly
irritating right now)

Re:date FIELD type


Quote
Trevor Jones wrote:

> Is there a workaround for dynamic linking?  My app is basically just a shell
> which loads a package loader which....

I plan on releasing a 6.01 patch that addresses this and a couple of other minor
bugs in the D6 version after BorCon.

--
Jeff Overcash (TeamB)   I don't think there are any Russians
(Please do not email    And there ain't no Yanks
 me directly unless     Just corporate criminals
 asked.  Thank You)     Playing with tanks.  (Michael Been)

Re:date FIELD type


In article <3B57BE3C.8E582...@onramp.net>, overc...@onramp.net says...
Quote
> Trevor Jones wrote:

> > Is there a workaround for dynamic linking?  My app is basically just a shell
> > which loads a package loader which....

> I plan on releasing a 6.01 patch that addresses this and a couple of other minor
> bugs in the D6 version after BorCon.

Thanks Jeff.  

I'll stick with the server supplied default time until then...

I guess an IFDEF will get around development issues, I'll turn it off
after BorCon (and the patch).  Hope you enjoy it! Its a few years since
I've last been able to attend.

Other Threads