Re: [U2] [UV] Calculate age from date of birth

2007-01-17 Thread Thomas Derwin
Here's our routine (an external subroutine we've used for years, first
on Sequoia, then on Unidata):

:ED BP AGE.CALC
Top of "AGE.CALC" in "BP", 38 lines, 1,384 characters.
001: SUBROUTINE AGE.CALC (BIRTH.DATE , AS.OF.DATE , AGE)
002: 
003: *Author  : Tom Derwin
004: *Date: 8/22/95
005: *Req. by : Dianon Systems Inc.
006: *Job #   :
007: *
008: *Purpose : Return patient's age based on date of birth and "as
of"
009: *  date (e.g. collection date or today's date).
010: 
011: *   Begin History  (latest always on line 13)
012: *  DateReq byProgrammer/ Comments
013: * 08/22/95 n/a   T.Derwin  / New pgm, adapted from
FIND.AGE.SUB.
014: * End History
015: 
016: *
017: * Note: birth date & "as of" date are passed in internal format.
018: *
019: AGE = '' ; * Added RHH 1/26/95 so 'AGE' is always defined.
020: IF BIRTH.DATE = '' THEN RETURN
021: IF BIRTH.DATE MATCH '0N' OR BIRTH.DATE MATCH '-0N' THEN NULL ELSE
RETURN
022: IF AS.OF.DATE MATCH '0N' OR AS.OF.DATE MATCH '-0N' THEN NULL ELSE
RETURN
023: IF AS.OF.DATE = '' THEN AS.OF.DATE = DATE() ; * Default to today.
024: *
025: YR.DIFF = OCONV(AS.OF.DATE,'D4Y') - OCONV(BIRTH.DATE,'D4Y')
026: BIRTH.MONTH = OCONV(BIRTH.DATE,'DM')
027: AS.OF.MONTH = OCONV(AS.OF.DATE,'DM')
028: BEGIN CASE
029:   CASE AS.OF.MONTH > BIRTH.MONTH ; NULL
030:   CASE AS.OF.MONTH < BIRTH.MONTH ; YR.DIFF = YR.DIFF - 1
031:   CASE AS.OF.MONTH = BIRTH.MONTH
032: AS.OF.DAY = OCONV(AS.OF.DATE,'DD')
033: BIRTH.DAY = OCONV(BIRTH.DATE,'DD')
034: IF AS.OF.DAY < BIRTH.DAY THEN YR.DIFF = YR.DIFF - 1
035: END CASE
036: AGE = YR.DIFF
037: RETURN
038: *END
Bottom.

Have fun,
Tom

>>> [EMAIL PROTECTED] 01/16/07 4:04 PM >>>
Hi,
Could anyone tell me how I can calculate someones age from their date of
birth at a specific point in time? ie, age at 6 April 2006 if their date
of
birth is 12 October 1967.

Thanks,
Dom

-
This e-mail and any attachments may contain CONFIDENTIAL
information, including PROTECTED HEALTH INFORMATION. If you are not
the intended recipient, any use or disclosure of this information
is STRICTLY PROHIBITED; you are requested to delete this e-mail and
any attachments, notify the sender immediately, and notify the
LabCorp Privacy Officer at [EMAIL PROTECTED] or call (877)
23-HIPAA / (877) 234-4722.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Calculate age from date of birth

2007-01-17 Thread Oaks, Harold
Dom:

Use my routine posted earlier, but insert the target date instead of
date():

Suppose variable DOB holds the date of birth in internal format.
Suppose TARGET is the 'as of' date in internal format also.

  DOBX = OCONV(DOB,'D4/')
  DOB.YR = DOBX[7,4]
  DOB.DA = DOBX[4,2]
  DOB.MO = DOBX[1,2]

  TARGETX = OCONV(DATE(),'D4/')
  TARGET.YR = TARGETX[7,4]
  TARGET.DA = TARGETX[4,2]
  TARGET.MO = TARGETX[1,2]

  AGE = TARGET.YR - DOB.YR
  * We will subtract 1 from age if the 'now' month & day is earlier
in the
  * year than the 'dob' month & day, otherwise not

  IF TARGET.MO < DOB.MO THEN
 AGE = AGE - 1
  END ELSE
 IF TARGET.MO = DOB.MO AND TARGET.DA < DOB.DA THEN
AGE = AGE - 1
 END
  END
  * The variable AGE now holds their age as of the target date.

Harold Oaks
Sr. Programmer/Analyst
Clark County, WA

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Darren
Macdonald
Sent: Wednesday, January 17, 2007 4:57 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] [UV] Calculate age from date of birth

Perhaps a better way to do this would be to calculate a 'born before
date'.

This may save on processing time as well...

So, everyone born before 17/01/1942 is 65 or older.

HTH

Darren

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dominion
Sent: 16 January 2007 21:05
To: u2-users@listserver.u2ug.org
Subject: [U2] [UV] Calculate age from date of birth

Hi,
Could anyone tell me how I can calculate someones age from their date of
birth at a specific point in time? ie, age at 6 April 2006 if their date
of birth is 12 October 1967.

Thanks,

Dom
--
View this message in context:
http://www.nabble.com/-UV--Calculate-age-from-date-of-birth-tf3023501.ht
ml#a8398858
Sent from the U2 - Users mailing list archive at Nabble.com.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Calculate age from date of birth

2007-01-17 Thread Allen Egerton

Mark Olarte wrote:

Okay, to be truly accurate - divide by 365.25.  (3 * 365) + 366 = 1461
total days in a four year span including a leap year.  1461 / 4 =
365.25.


Apparently in my world last night leap year had one LESS day...

--
Allen
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Calculate age from date of birth

2007-01-17 Thread Darren Macdonald
Perhaps a better way to do this would be to calculate a 'born before
date'.

This may save on processing time as well...

So, everyone born before 17/01/1942 is 65 or older.

HTH

Darren

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dominion
Sent: 16 January 2007 21:05
To: u2-users@listserver.u2ug.org
Subject: [U2] [UV] Calculate age from date of birth

Hi,
Could anyone tell me how I can calculate someones age from their date of
birth at a specific point in time? ie, age at 6 April 2006 if their date
of
birth is 12 October 1967.

Thanks,

Dom
-- 
View this message in context:
http://www.nabble.com/-UV--Calculate-age-from-date-of-birth-tf3023501.ht
ml#a8398858
Sent from the U2 - Users mailing list archive at Nabble.com.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Calculate age from date of birth

2007-01-17 Thread Anthony W. Youngman
In message 
<[EMAIL PROTECTED]>, 
Timothy Snyder <[EMAIL PROTECTED]> writes

OOPS!!!  I need to correct what I just posted.  In the following statement:

Then, if the target MMYY is less than the birth MMYY, subtract one
from the age.

both of those references should say MMDD instead of MMYY.

Or use the Julian Day conversion code? Actually, I think that would mess 
up if either year was a leap year, so while a good idea it's actually to 
be avoided ...


Cheers,
Wol
--
Anthony W. Youngman <[EMAIL PROTECTED]>
'Yings, yow graley yin! Suz ae rikt dheu,' said the blue man, taking the
thimble. 'What *is* he?' said Magrat. 'They're gnomes,' said Nanny. The man
lowered the thimble. 'Pictsies!' Carpe Jugulum, Terry Pratchett 1998
Visit the MaVerick web-site -  Open Source Pick
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Calculate age from date of birth

2007-01-16 Thread Timothy Snyder
OOPS!!!  I need to correct what I just posted.  In the following statement:
> Then, if the target MMYY is less than the birth MMYY, subtract one
> from the age.
both of those references should say MMDD instead of MMYY.


Tim Snyder
Consulting I/T Specialist
U2 Consulting
North American Lab Services
IBM Software Group
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Calculate age from date of birth

2007-01-16 Thread Timothy Snyder
[EMAIL PROTECTED] wrote on 01/16/2007 07:36:53 PM:

> Okay, to be truly accurate - divide by 365.25.  (3 * 365) + 366 = 1461
> total days in a four year span including a leap year.  1461 / 4 =
> 365.25.

Actually, this isn't 100% accurate.  There are quite a few dates for which
this will generate an age that is off by one year.  I created a
demonstration program a long time ago to prove this, because we had a
program that was using this logic.  It never seemed quite right to me, and
it is right *almost* every time.  Calculating ages as of January 16, 2007
for all dates in the last ten years will show incorrect ages for January 16
of the following years: 1997, 1998, 2001, 2002, 2005, and 2006.  For
example, January 16, 2006 shows as zero years old (365/365.25 is less than
1).

My preferred method of calculating age is to extract the month, day, and
year of both dates and calculate the age as the difference between the
years.  Then, if the target MMYY is less than the birth MMYY, subtract one
from the age.  In other words, pretty much the way you would do it in your
head - or at least the way I do it in my head. ;-)  This also handles all
leap-year rules, including those funky 100- and 400-year ones, which are
not accommodated by simply dividing by 365.25.

Tim Snyder
Consulting I/T Specialist
U2 Consulting
North American Lab Services
IBM Software Group
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Calculate age from date of birth

2007-01-16 Thread Mark Olarte
Okay, to be truly accurate - divide by 365.25.  (3 * 365) + 366 = 1461
total days in a four year span including a leap year.  1461 / 4 =
365.25.

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Allen Egerton
> Sent: Tuesday, January 16, 2007 3:53 PM
> To: u2-users@listserver.u2ug.org
> Subject: Re: [U2] [UV] Calculate age from date of birth
> 
> Mark Olarte wrote:
> > Dom,
> > 
> > Dividing that by 365 gives you 38.51 ...
> > approximately 38 years and 186 days old.  HTH.
> > 
> > Mark
> 
> Quibble - divide by 364.25, (leap year).
> 
> --
> Allen
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] [UV] Calculate age from date of birth

2007-01-16 Thread Allen Egerton

Mark Olarte wrote:

Dom,

You could ICONV both dates and subtract to get the total number of days
between the two.  6 April 2006 = 13976.  12 October 1967 = -80.
Subtracting gives you 14056.  Dividing that by 365 gives you 38.51 ...
approximately 38 years and 186 days old.  HTH.

Mark


Quibble - divide by 364.25, (leap year).

--
Allen
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Calculate age from date of birth

2007-01-16 Thread dsig
Hope this isn't a trick question 

Normally you will get the internal date for both birth and 'test' date
then simply subtract.  One thing to keep in mind is that anything
before 12/31/67 will be neg as 12/31/67 is day 0

so internal bdate 10/12/67 is -80 and internal test date 4/6/2006 is
13976.

In this case we want 13976 + abs -80 = 14056/4

iBdate = abs( iconv('10/12/67','D') )
iTestDate = iconv('4/6/06','D')

iTotDays = iBdate + iTestDate

iYears = int( iTotDays/4 )


*note .. the previous does not take into account leap year etc.

DSig
David Tod Sigafoos
SigsSolutions, Inc.


>  Original Message 
> Subject: [U2] [UV] Calculate age from date of birth
> From: Dominion <[EMAIL PROTECTED]>
> Date: Tue, January 16, 2007 1:04 pm
> To: u2-users@listserver.u2ug.org
> 
> Hi,
> Could anyone tell me how I can calculate someones age from their date of
> birth at a specific point in time? ie, age at 6 April 2006 if their date of
> birth is 12 October 1967.
> 
> Thanks,
> 
> Dom
> -- 
> View this message in context: 
> http://www.nabble.com/-UV--Calculate-age-from-date-of-birth-tf3023501.html#a8398858
> Sent from the U2 - Users mailing list archive at Nabble.com.
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Calculate age from date of birth

2007-01-16 Thread Boydell, Stuart
http://www.pickwiki.com/cgi-bin/wiki.pl?DateUtility

param = 'GetElapsedPeriod'
call DateUtility(param,birthdate)
currentAge = param ;* (years am months am days)

>-Original Message-
>Hi,
>Could anyone tell me how I can calculate someones age from their date
of
>birth at a specific point in time? ie, age at 6 April 2006 if their
date of
>birth is 12 October 1967.


 
**
This email message and any files transmitted with it are confidential and 
intended solely for the use of addressed recipient(s). If you have received 
this communication in error, please reply to this e-mail to notify the sender 
of its incorrect delivery and then delete it and your reply.  It is your 
responsibility to check this email and any attachments for viruses and defects 
before opening or sending them on. Spotless collects information about you to 
provide and market our services. For information about use, disclosure and 
access, see our privacy policy at http://www.spotless.com.au 
Please consider our environment before printing this email. 
** 
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Calculate age from date of birth

2007-01-16 Thread Mark Olarte
Dom,

You could ICONV both dates and subtract to get the total number of days
between the two.  6 April 2006 = 13976.  12 October 1967 = -80.
Subtracting gives you 14056.  Dividing that by 365 gives you 38.51 ...
approximately 38 years and 186 days old.  HTH.

Mark

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Dominion
> Sent: Tuesday, January 16, 2007 1:05 PM
> To: u2-users@listserver.u2ug.org
> Subject: [U2] [UV] Calculate age from date of birth
> 
> Hi,
> Could anyone tell me how I can calculate someones age from 
> their date of birth at a specific point in time? ie, age at 6 
> April 2006 if their date of birth is 12 October 1967.
> 
> Thanks,
> 
> Dom
> --
> View this message in context: 
> http://www.nabble.com/-UV--Calculate-age-from-date-of-birth-tf
> 3023501.html#a8398858
> Sent from the U2 - Users mailing list archive at Nabble.com.
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] [UV] Calculate age from date of birth

2007-01-16 Thread Larry Hiscock
What units do you want it in?  Days?  Years and fractional parts of years?
Years, months & days?

Larry Hiscock
Western Computer Services
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dominion
Sent: Tuesday, January 16, 2007 1:05 PM
To: u2-users@listserver.u2ug.org
Subject: [U2] [UV] Calculate age from date of birth

Hi,
Could anyone tell me how I can calculate someones age from their date of
birth at a specific point in time? ie, age at 6 April 2006 if their date of
birth is 12 October 1967.

Thanks,

Dom
--
View this message in context:
http://www.nabble.com/-UV--Calculate-age-from-date-of-birth-tf3023501.html#a
8398858
Sent from the U2 - Users mailing list archive at Nabble.com.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/