Calculating age in QUIZ

Pickering, John (NORBORD) PICKERIJ@norbord.com
Tue, 4 Dec 2001 15:28:04 -0500


George

Try this. Freshly whipped up so no warranties expressed or implied. Assumes
8 digit dates everywhere. May or may not give what you want if either date
falls on Feb 29. But it's probably close enough for Microsoft work :-)

Regards,
JWP

> define d-bd date = parm prompt "Birthday: "
> define d-to date = parm prompt "End date: "
> 
> define d-to-yyyy int*4 = ncon(ascii(d-to,8)[1:4])
> define d-to-mmdd int*4 = ncon(ascii(d-to,8)[5:4])
> define d-bd-yyyy int*4 = ncon(ascii(d-bd,8)[1:4])
> define d-bd-mmdd int*4 = ncon(ascii(d-bd,8)[5:4])
> 
> define d-years int*3 &
>   =    d-to-yyyy - d-bd-yyyy &
>     if d-to-mmdd ge d-bd-mmdd &
>   else d-to-yyyy - d-bd-yyyy -1 &
>     if d-to-yyyy ne d-bd-yyyy &
>   else 0
> 
> define d-days int*3 &
>   =    0 &
>     if d-bd-mmdd = d-to-mmdd &
>   else days(ncon(ascii(d-bd-yyyy,4) + "1231")) - days(d-bd) + 1 &
>      + days(d-to) - days(ncon(ascii(d-to-yyyy,4) + "0101")) &
>     if d-bd-mmdd gt d-to-mmdd &
>   else days(d-to) &
>      - days(ncon(ascii(d-to-yyyy,4) + ascii(d-bd-mmdd,4))) &
>     if 0229 ne d-bd-mmdd or &
>        0229 =  d-to-mmdd &
>   else days(ncon(ascii(d-bd-yyyy,4) + ascii(d-to-mmdd,4))) &
>      - days(d-bd)
> 
> report d-bd d-to d-years d-days
> 

> -----Original Message-----
> From:	George_DeWolf@midhosp.org [SMTP:George_DeWolf@midhosp.org]
> Sent:	Tuesday, December 04, 2001 1:54 PM
> To:	powerh-l@lists.swau.edu
> Subject:	Calculating age in QUIZ
> 
> Looking for good routine to determines age in years and days, given a
> birth
> date, that takes into account leap years.  Running QUIZ 8.19.C5 on the
> HP3000.
> 
> = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> Mailing list: powerh-l@lists.swau.edu
> Subscribe: "subscribe" in message body to powerh-l-request@lists.swau.edu
> Unsubscribe: "unsubscribe" in message body to
> powerh-l-request@lists.swau.edu
> http://lists.swau.edu/mailman/listinfo/powerh-l
> This list is closed, thus to post to the list you must be a subscriber.