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


You will receive more knowledgable answers in the
borland.public.delphi.sqlservers newsgroup.    This group is for
desktop databases.    I recall having a similar problem in Delphi 1
and SQL Server 6.5 a couple of years ago.   I ended up using a stored
proc and the SQL Server "convert" function.
e.g. convert(smalldatetime, yourdatevalue).

Before resorting to that, you might try to bypass the date/time
conversions with:

dmfMain.tblTable1.FieldByName('SignInDate').Assign(dmfMain.tblTable2.FieldByName('SignInDate'));

regards,
Colin Acheson

On Wed, 27 Dec 2000 07:50:18 -0700, "Pam" <parke...@zdnetonebox.com>
wrote:

Quote
>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??

Re:datetime data type to smalldatetime data type conversion error


Hi Pam,

Have you tried:
dmfMain.tblTable1.FieldByName('SignInDate').Value :=
dmfMain.tblTable2.FieldByName('SignInDate').Value;

Good Luck!
Debbie

Quote
"Pam" <parke...@zdnetonebox.com> wrote in message

news:3a4a1046_1@dnews...
Quote
> 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