Board index » delphi » datetime data type to smalldatetime data type conversion error

datetime data type to smalldatetime data type conversion error

Hi,

Using Delphi 5 and SQL Server 7, I am trying to assign a smalldatetime field
in one table to another smalldatetime field in another table via this
assignment code:

dmfMain.tblTable1.FieldByName('SignInDate').AsDateTime :=
dmfMain.tblTable2.FieldByName('SignInDate').AsDateTime;

Regardless of what I try (dmfMain.tblTable1['SignInDate'] :=
dmfMain.tblTable1['SignInDate'] or using an intermediate variable), I
continually get the following error:

'The conversion from datetime data type to smalldatetime data type resulted
in a smalldatetime overflow error.'

Any ideas on why this is happening even though both fields have the exact
same field definition??

TIA,
Pam

 

Re:datetime data type to smalldatetime data type conversion error


Pam,

I noticed your thread in the objectpascal newsgroup, and saw you haven't
been able to get an answer. I too suffer from this from time to time.

I'm not exactly sure why you're having a problem, but I'd think it has to do
with the floating point conversion involved with the time portion of
datetimes. A first guess ata solution would be to use formatdatetime to
write the record.

dmfMain.tblTable1.FieldByName('SignInDate').string :=
formatdatetime ('Whatever format you want',
dmfMain.tblTable2.FieldByName('SignInDate').AsDateTime)

Hopefully this will work or someone else will notice if I gave you bad
scoop...

Mike Walsh

Quote
"Pam" <parke...@zdnetonebox.com> wrote in message news:3a4b45dd_1@dnews...
> Hi,

> Using Delphi 5 and SQL Server 7, I am trying to assign a smalldatetime
field
> in one table to another smalldatetime field in another table via this
> assignment code:

> dmfMain.tblTable1.FieldByName('SignInDate').AsDateTime :=
> dmfMain.tblTable2.FieldByName('SignInDate').AsDateTime;

> Regardless of what I try (dmfMain.tblTable1['SignInDate'] :=
> dmfMain.tblTable1['SignInDate'] or using an intermediate variable), I
> continually get the following error:

> 'The conversion from datetime data type to smalldatetime data type
resulted
> in a smalldatetime overflow error.'

> Any ideas on why this is happening even though both fields have the exact
> same field definition??

> TIA,
> Pam

Other Threads