Board index » delphi » Delphi and 4-digit-year

Delphi and 4-digit-year

Hello there,

i use delphi2 with sql server.
i try to inesert a datetime field into my database.
i assign the value the following way:
  fieldbyname('BirthDate').AsString := '25.01.1945';
the bde converts this to 25.01.45 , *without* century ( 19... ).
When it arrives that way at sql server, it interprets it as 25.01.2045.
( which is according to its documentation ).
That means, I have to send the date *with* the century.
How can  I delphi make to do this?

In the BDE, fourdigityear is true,
dateformat ( long & short ) are both set to 4-digit.

PLease help!

regards,
  Markus

 

Re:Delphi and 4-digit-year


Quote
In article <5f4cfk$17...@news.belwue.de> voel...@rz-nov2.rz.fh-weingarten.de (Markus Voelter) writes:
>i use delphi2 with sql server.
>i try to inesert a datetime field into my database.
>i assign the value the following way:
>  fieldbyname('BirthDate').AsString := '25.01.1945';
>the bde converts this to 25.01.45 , *without* century ( 19... ).
>When it arrives that way at sql server, it interprets it as 25.01.2045.
>( which is according to its documentation ).
>That means, I have to send the date *with* the century.
>How can  I delphi make to do this?
>In the BDE, fourdigityear is true,
>dateformat ( long & short ) are both set to 4-digit.

I would consider this behavior of the 'AsString' property to be either a bug
or something unacceptably close to it.  I feel that Borland should investigate
this behavior and publish, widely, a way to control this behavior of
'AsString.'

Even if the problem is not a true "bug," it is an issue of sufficient
timeliness (ahem) that a published direction on this issue would be
politically advantageous.  A perceived-weakness like this will not escape the
eyes of the Microsoft marketing-department for long, especially as the VB5
publicity/smearing campaign gets under way.

What you can do, in the meantime, is to convert the date yourself using one of
the library functions and use the 'AsDateTime' property to assign the field.

If this does not work -- if the SQL Server driver converts the value
incorrectly -- then the problem is elevated to "unquestionably a show stopper
and WHAT do we do about it?!"

/mr/

Re:Delphi and 4-digit-year


Try fieldbyname('BirthDate').asdatetime:=trunc(strtodate('25.01.1945'));

Nick Spurrier (MoDESoft, UK)

Re:Delphi and 4-digit-year


Perhaps it has something to do with the Windows ?? date format in the
control panel. Check that this is set to the 4 digit year.

Markus Voelter <voel...@rz-nov2.rz.fh-weingarten.de> wrote in article
<5f4cfk$17...@news.belwue.de>...

Quote
> Hello there,

> i use delphi2 with sql server.
> i try to inesert a datetime field into my database.
> i assign the value the following way:
>   fieldbyname('BirthDate').AsString := '25.01.1945';
> the bde converts this to 25.01.45 , *without* century ( 19... ).
> When it arrives that way at sql server, it interprets it as 25.01.2045.
> ( which is according to its documentation ).
> That means, I have to send the date *with* the century.
> How can  I delphi make to do this?

> In the BDE, fourdigityear is true,
> dateformat ( long & short ) are both set to 4-digit.

> PLease help!

> regards,
>   Markus

Re:Delphi and 4-digit-year


 Try to use FieldByName('BirthDate').AsDateTime := StrToDate('25.01.1945')

Other Threads