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: * Date Req by Programmer / 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/