Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A twist on age calculation.
Message
De
06/01/2005 07:47:01
 
 
À
04/01/2005 11:04:08
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
00973330
Message ID:
00974649
Vues:
46
>>>>>Fabio,
>>>>>I already sent an age calculation that returns those expected dates:)
>>>>>Here is it shortenehed:
>>>>>
>>>>
>>>>
>>>>Sorry
>>>>
>>>>.CalcAge({^1988/2/29} ,  {^1991/2/27 })
>>>>Observed 2 , 11,  30
>>>>Expected 2 , 11,  29
>>>>
>>>>
>>>>Fabio
>>>
>>>Why 29? 30 is correct.
>>>Cetin
>>
>>
>>{^1988/2/29} + 2 years + 11 month + 0 days = {^1991/1/29}
>>? {^1991/1/29}+30
>>
>
>If you're born before March 1st, then next year you're 1 year older before March 1st, right?
>
>{^1988/2/29} + 2 years = {^1990/2/28} && 2 years old now
>{^1990/2/28} + 11 months = {^1991/1/28}
>{^1991/1/28} + 30 days = {^1991/2/27}
>
>Cetin

Hi Cetin.

Right. My error. I use YMD difference, but compute MD difference.

Now i have fully definition for difference of two dates:
*   D = Days                => dEnd = dBegin + Days
*  MD = Months,Days         => dEnd = GOMONTH(dBegin,Months)+ Days
* YMD = Years,Months,Days   => dEnd = GOMONTH(GOMONTH(dBegin,12*Years),Months)+ Days
Important:
the Associative Rule is not valid for Y,M or M additions
That is:
YMD = (2,1,3) <> (1,0,0)+(1,1,3)
But, i check YMD, and your CalcAge lose a day when dBegin is 29/2/XXXX :
CalcAge({^1988/2/29} ,  {^2006/9/14 })
Observed : 18,6,16
Expected : 18,6,17
*{^1988/2/29} + 18 years = {^2006/2/28} + 6 months = {^2006/8/28} + 16 = {^2006/9/13}
Fabio
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform