Board index » delphi » TDateTime values from Delphi 1 to Delphi 3

TDateTime values from Delphi 1 to Delphi 3

My Delphi 1 program saves and loads TDateTime values via a Text File.  The
dates are correctly decoded in Delphi 1 using the DeCodeDate procedure.

I have the exact same program, but this time in Delphi 3.  Again it saves
and loads TDateTime values via a Text File.  And again theses dates are
correctly decoded in Delphi 3 using the DeCodeDate procedure.

However when I load a TDateTime value in Delphi 3 from a file that was
created using Delphi 1 then I hit a problem.  The year value returned from
the DeCodeDate procedure is showing 3898 instead of 1999!

So, I looked at the values created by the DATE function in both Delphi 1 and
Delphi 3 and they are completely different.  Todays date 11th Feb 1999 for
example showed these values:

  Delphi 1 = 7.29796000000000E+0005
  Delphi 3 = 3.62020000000000E+0004

Why?

I need to upgrade my users into 32 bit, how can I get around this problem?
I don't really won't to minus 1899 from a year that is beyond xxxx because
users may want to use large years for some reason.

Thanks in advance for any suggestion.

Regards,
Paul.

 

Re:TDateTime values from Delphi 1 to Delphi 3


Quote
Paul Linsell wrote:

> My Delphi 1 program saves and loads TDateTime values via a Text File.  The
> dates are correctly decoded in Delphi 1 using the DeCodeDate procedure.

> I have the exact same program, but this time in Delphi 3.  Again it saves
> and loads TDateTime values via a Text File.  And again theses dates are
> correctly decoded in Delphi 3 using the DeCodeDate procedure.

> However when I load a TDateTime value in Delphi 3 from a file that was
> created using Delphi 1 then I hit a problem.  The year value returned from
> the DeCodeDate procedure is showing 3898 instead of 1999!

> So, I looked at the values created by the DATE function in both Delphi 1 and
> Delphi 3 and they are completely different.  Todays date 11th Feb 1999 for
> example showed these values:

>   Delphi 1 = 7.29796000000000E+0005
>   Delphi 3 = 3.62020000000000E+0004

> Why?

> I need to upgrade my users into 32 bit, how can I get around this problem?
> I don't really won't to minus 1899 from a year that is beyond xxxx because
> users may want to use large years for some reason.

> Thanks in advance for any suggestion.

> Regards,
> Paul.

The D3 help file says:

"Delphi 1.0 calculated the date from year 1 instead of from 1899. To convert
a Delphi 1.0 date to a Delphi 2.0 date, subtract 693594.0 from the Delphi
1.0 date. The date format changed to be more compatible with OLE 2.0
Automation"

You could write a conversion program that your users have to run when then
upgrade to the 32-bits version. Or change the old dates running the
installation program of the new version.

Sasan.

Re:TDateTime values from Delphi 1 to Delphi 3


In article <36C5C2E0.C30F6...@hotmail.com>, Fabio Giliberti

Quote
<fgilibe...@hotmail.com> writes:
>Reading the help about TDateTime I think this is the fastest way...

>Function TForm1.Calcoladata(GG,MM,YY,Hours,Mins:Byte):TDateTime;

Ignoring the minor error (it should be (GG,MM : byte; YY : word;
Hours,Mins:Byte)) there is no improvement in the time to calculate 10000 over
:-

    MyDateTime := EncodeDate(1998, 7, 23) + EncodeTime(11, 47, 13, 24);

 . . . which seems to me clearer and easier. <gg>

Re-inventing the wheel does not always produce a rounder wheel, nor one which
rolls faster <g>

Alan Lloyd
alangll...@aol.com

Re:TDateTime values from Delphi 1 to Delphi 3


On 14 Feb 1999 12:51:10 GMT, alangll...@aol.com (AlanGLLoyd) wrote:

Quote

>In article <36C5C2E0.C30F6...@hotmail.com>, Fabio Giliberti
><fgilibe...@hotmail.com> writes:

>>Reading the help about TDateTime I think this is the fastest way...

>>Function TForm1.Calcoladata(GG,MM,YY,Hours,Mins:Byte):TDateTime;

>Ignoring the minor error (it should be (GG,MM : byte; YY : word;
>Hours,Mins:Byte)) there is no improvement in the time to calculate 10000 over
>:-

>    MyDateTime := EncodeDate(1998, 7, 23) + EncodeTime(11, 47, 13, 24);

> . . . which seems to me clearer and easier. <gg>

>Re-inventing the wheel does not always produce a rounder wheel, nor one which
>rolls faster <g>

You are of course right on this one, but I think this thread reveals a
little problem with the Delphi help files, they are not always very
intuitive, and Pascal who asked the question in the first place did
also mention that the files were hard to search in.
It has happened to me a couple of times that I have made my own
function/procedure before I occasionally ran into the right function.
In this case I knew about the EncodeDate, but a search for "date" in
the help files did not lead me to it.

Geir
--
Geir Tutturen
email: geir.tuttu...@mail.link.no

Other Threads