Patrick
Why Not!
Because an Elapsed Period (ie DateTime1-DateTime2) is not a DateTime it is a
Number of Days in Double format
To correctly Decode an Elapsed period into days/months/years you would need
to have a function like
DecodeDate(StartDate: TDateTime; Days: Double; var Year, Month, Day: Word);
begin
balh blah
end;
The problem being the Month Day values due to varying length of months! (not
to mention leap years)
Which remonds me, I had a friend who went to his grandads 21st....
On this point the 12/30/1899 12:00 am is the 0 point for TDateTimes and -ve
values are quite valid (according to Delphi docs see TDateTime type) but the
DecodeDate function does not accept -ve TDateTimes which is the only
inconstintentcy I can see so
the solution is to rename DecodeDate as DecodeDatePast1900 and then we will
all be happy
and it is all M$ fault because
Note: 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.
Regards Neven
N.K. MacEwan B.E. E&E
> > I was just commenting on someone who emailed that DecodeDate of some
such
> > function didn't give the the correct difference (in Years month days) on
a
> > Date Differential (which of course it cant and is not designed to)
>
> Why not?
>
> All DecodeDate does is turn a number into a year/month/day representation
> and in so doing it adds an offset of 30/12/1899 to it. What I asked for is
> very simple - that the offset not be added.
>
> ============================================
> Patrick Dunford, Christchurch, NZ
> http://patrick.dunford.com/
>
>
> --------------------------------------------------------------------------
-
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz