Retrieve date of birth given age in CLP

Here's a quick method to get the DOB without having to create a service program.

I was faced with this problem of using OPNQRYF to extract a list base on the person's age (i.e. Age must be greater or equal to 18). The file has a Date of Birth field. In order to soft-code this method, I need to get the date of birth (DOB) to compare with person's birth date. The quickest method to get the DOB without having to create a service program is to use the 8870 method. This method is used by genealogist in calculating D...

OB.

Because of the change from Julian to Gregorian calendar, this method will not work if DOB is between September 2, 1752 and September 14, 1752.

Substitute the yymmdd (e.g. 180000) below if you want the exact age. For example, 21 year 8 months 10 days will have a value of 210810.


 
  
        dcl        &Lilian    *dec     9               
             dcl        &Second    *char    8               
             dcl        &GregDt    *char   17               
             dcl        Πcture   *char    8   'YYYYMMDD'  
             dcl        &BirthDt   *char    8               
             dcl        &Dob       *dec     8               
             dcl        &DobYYYY   *dec     4               
             dcl        &DobMM     *dec     2               
             dcl        &DobDD     *dec     2               

/*--------------------------------------------------------*/
/*  Select only age 18 & above. Calculate Date of Birth   */
/*  using the 8870 method.                                */
/*                                                        */
/*  Today's date in yyyymmdd       20030122               */
/*  - 18 years old in yymmdd      -  180000               */
/*  -------------------------      --------               */
/*                                 19850122               */
/*  - 8870 (30 days length)       -    8870               */
/*  -------------------------      --------               */
/*                                 19841252               */
/*                                                        */
/*  Adjust if dd is > 30        dd = 52 - 30   = 22       */
/*                              mm = 12 + 1    = 01       */
/*                            yyyy = 1984 + 1  = 1985     */
/*                                                        */
/*  After date adjustment          19850122 is DOB        */
/*                                                        */
/*--------------------------------------------------------*/
             callprc    CEELOCT        (&Lilian            +
                                        &Second            + 
                                        &GregDt  )           
             callprc    CEEDATM        (&Second            + 
                                        Πcture           + 
                                        &BirthDt           + 
                                        *OMIT    )           
             chgvar     &Dob           &BirthDt              
             chgvar     &Dob           (&Dob - 180000 - 8870)
             chgvar     &BirthDt       &Dob                  
             If         (%sst(&BirthDt  7 2) > '30')       do
               chgvar     &DobYYYY       %sst(&BirthDt  1  4)
               chgvar     &DobMM         %sst(&BirthDt  5  2)
               chgvar     &DobDD         %sst(&BirthDt  7  2)
               chgvar     &DobDD         (&DobDD - 30)       
               chgvar     &DobMM         (&DobMM + 1)        
               if         (&DobMM > 12)                    do
                 chgvar     &DobMM         (&DobMM - 12)     
                 chgvar     &DobYYYY       (&DobYYYY + 1)    
               enddo                                         
               chgvar     %sst(&BirthDt  1  4)   &DobYYYY    
               chgvar     %sst(&BirthDt  5  2)   &DobMM      
               chgvar     %sst(&BirthDt  7  2)   &DobDD      
               chgvar     &Dob           &BirthDt            
             Enddo                                           
This was first published in January 2003

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close