Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Age calculation to Fabio Lunardon
Message
From
17/10/2006 09:05:21
 
 
To
16/10/2006 20:15:56
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01162377
Message ID:
01162521
Views:
18
>Dear Fabio Lunardon and others, who discussed age calculation 3 weeks ago.
>
>>Birth = {^1988/2/29}
>>* Age in {^1989/3/01} is: 1 years 0 months 1 day
>
>>* Age in {^1989/2/28} is ?
>>* if age= 0 years 11 months and 30 days
>>* and age 1 year is not possible ( the person it doesn't have birthday)
>
>>* then the possible choice is only:
>>* in {^1989/2/28} is : 1 years 0 months 0 days
>>result: the only common sense is
>>age=((years)+months)+days
>>today = ((birth+years)+months)+days
>
>>and age's days are the last lived days
>
>
>Yes, that's correct. But does it mean, that on {^1989/3/28} this person is 1 years 1 months 0 days old?

No, of course

>IF the answer is "No", then
> .CalcAge({^1988/2/29},{^2006/9/14})
> * should give 18,6,16 (not expected 18,6,17)
>
NOT TRUE.

* the age go forward only, then, and the metric it is orderly Y,M,D or M,D or D .

But another point is:
Which question do you do to a person?

You can ask:
1) when were you born?
or
2) when you complete the years in the current year?

example

* an age day
.CalcAge({^1988/2/29},{^2006/2/27}) = 17,11,27
* month = 2 and day = last month's day ( a match is not possible ),
then reset days, carry a month,
* month = 12 = 1 year, then reset months, carry a year
.CalcAge({^1988/2/29},{^2006/2/28}) = 18,0,0 * on current year the birth day is 28

* add a day
.CalcAge({^1988/2/29},{^2006/3/01}) = 18,0,1
* ....


* birth day = 29 then
1) .CalcAge({^1988/2/29},{^2006/3/28}) = 18,0,28
* and
.CalcAge({^1988/2/29},{^2006/9/14}) = 18,6,16

* but on this year the birth day is 28 ! then
2) .CalcAge({^1988/2/29},{^2006/3/28}) = 18,1,0
* and
.CalcAge({^1988/2/29},{^2006/9/14}) = 18,6,17

WITH the 1) you uses a M,D metric, and convert it to Y,M,D with Y=12M

* check is GOMONTH(DOB,.Years*12+.Months)+.Days

WITH the 2) you uses a pure Y,M,D metric
* check is GOMONTH(GOMONTH(DOB,.Years*12),.Months)+.Days



>ELSE &&answer is "Yes"
> Then consider the following example (and just think about January month as a leap month comparing with February).
>
>1st person DOB {^2006/01/28}
>2nd person DOB {^2006/01/29}
>3rd person DOB {^2006/01/30}
>
>Then on {^2006/02/27} they have
>1st 0 years 0 months 30 days
>2nd 0 years 0 months 29 days
>3rd 0 years 0 months 28 days
>
>But on {^2006/02/28} they all have birthday (it's not possible a person doesn't have birthday), so
>1st 0 years 1 months 0 days
>2nd 0 years 1 months 0 days
>3rd 0 years 1 months 0 days
>
>And then, follow your logic, if we go further, they all must have the SAME age. But I believe, the normal people would say, that on {^2006/03/30} there:
>1st 0 years 2 months 2 days
>2nd 0 years 2 months 1 days
>3rd 0 years 2 months 0 days
>ENDIF &&answer="no/yes"
>

Then on {^2006/02/27} they have
1st 0,0,30
2nd 0,0,29
3rd 0,0,28

But on {^2006/02/28} they all have birthday (it's not possible a person doesn't have birthday), so
1st 0,1,0
2nd 0,1,0
3rd 0,1,0

And then, follow your logic, if we go further, they all must have the SAME age.

* this is not my logic

ON {^2006/03/30} my logic is:

1st 0,2,2
2nd 0,2,1
3rd 0,2,0
ENDIF &&answer="no/yes"


>What I'm talking about: the correct test is NOT:
>
>GOMONTH(GOMONTH(DOB,.Years*12),.Months)+.Days
>
>but:
>
>GOMONTH(DOB,.Years*12+.Months)+.Days
>
>Age calculators were duscussed a lot of times on www.foxite.com. If somebody still is interested, here the links to threads with my code (I would be really glad to hear your comments):
>http://www.foxite.com/archives/its-not-a-good-code-0000061206.htm
>http://www.foxite.com/archives/another-code-0000068848.htm
>
>Sorry if I'm too late.
>
>Regards,
>Sergey
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform