Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compute a person's age today based on his date of birth.
#21
Neo and Deleter,

Check me out on the following:

I think the logic that both of you have at the end of the program where you finally compute the person's age, is a bit complicated. It has too many IF's.

They way I see it is as follows:

* We have done all the validations already, including that the date of birth is not in the future.

* Create a 4 byte variable called BMMDD$ which contains the month and day of the birth date.

* Create another 4 byte variable called CMMDD$ from the current date.

* We should already have a numeric variable called BYEAR for the year of the date of birth, and one called CYEAR for the year from the current date.


* Now we're ready to compute the AGE:
Code:
AGE = CYEAR - BYEAR
IF BMMDD$ < CMMDD$ THEN AGE = AGE - 1
You guys have been testing this problem much more than I, so tell me, will the above work? If not, why?

Thanks.
*****
Reply


Messages In This Thread
Compute a person's age today based on his date of birth. - by Moneo - 06-11-2005, 07:07 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)