On 11/12/2013 3:40 PM, John Landmesser wrote:
On 12.11.2013 21:01, waldo kitty wrote:
[...]
Which is correct?

Date1 := 29.2.2000
Date2 := 28.02.2001

Your function:
0 Y, 11 M, 27 D

Rxlib ( Jedi ) DateDiff:
0 Y, 11 M, 28 D

Libre Office Calc:
0 Y, 11 M, 30 D

The table - function of Libre Office Calc is called in german DATUMDIF()

Get a calendar and count??

actually, i have in some cases... let's ask this question and see what your charts and routines return as the result... assuming your format is DD.MM.YYYY...

Date1 := 01.01.2000
Date2 := 01.01.2000

should be 0 (zero), right?

then

Date1 := 01.01.2000
Date2 := 02.01.2000

should be 1 (one), right?

in this case, what i (and bart, too) wrote, we're not counting the starting day but we are counting the ending day... this rule stays in effect throughout the entire process... my head still aches from rummaging about doing this... it was good exercise and one i remember being given on a test many years back to determine one's coding level... at that time, the code was being done in dBase II/III/IV ;)

i will have to dig deeper and see what is crossing things up for count from 29.02.2000 to 28.02.2001... i see bart has posted a fix which i have not yet had a chance to compare with my code or run thru the tests i included in my posting...

the real question is this:

  what do we count? the starting day, the ending day, both days or neither day?

then we have another question:

  is dayM in monthY a one month difference to dayM in monthX and
  monthZ? monthX, monthY, monthZ are any three consecutive months
  in linear order within one year or crossing two years

once the rules are chosen, then we have something to work with...

--
NOTE: No off-list assistance is given without prior approval.
      Please keep mailing list traffic on the list unless
      private contact is specifically requested and granted.

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to