Calculating age and years of service

Jose Lerebours fp at fpgroups.com
Mon Oct 20 08:15:47 PDT 2008


fp at mccabes.us wrote:
> Hello,
> 
> I am trying to calculate a person's age from their date of birth, also  
> I am trying to get years of service down to the day.  I have the dates  
> in the filePro file, and I want to base it off of today's date.
> 
> If I use something such as "ag=@td-1", I get a number such as 20763.  
> If I divide by 365, I can get 56.8849135 years, I can use that for the  
> age.  But for years of service I was looking for more data, such as "X  
> years, Y months, Z days."
> 
> Any suggestions would be helpful.
> 
> Thanks,

Dan,

Check this out:

   1  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
@keym  þ If: 

        Then: dim info(3)(6,.0) 

   2  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: ya(8,mdy/)="01/17/72"; yb(8,mdy/)=@td; gosub LOOPAGE 

   3  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: info("1")=int(info("2")/"12") ; info("3")=yc-yb 

   4  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: info("2")=(frac(info("2")/"12"))*"12" 

   5  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: yx="Y: "&info("1")&"\nM: "&info("2")&"\nD: " 

   6  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: yx=yx&info("3"); show ""; msgbox yx 

   7  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: end 

   8  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
LOOPAGEþ If: 

        Then: yd(4,.0)=eom(dom(ya)); yd=eom(ya)+yd; yc(8,mdy/)=ya+yd 

   9  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: ya eq yc 

        Then: yc=eom(yc+"1") 

  10  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: yc gt yb 

        Then: return 

  11  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: info("2")=info("2")+"1"; ya=yc; goto LOOPAGE 



Please note that I have not tested this beyond what is shown and you 
should test/modify code prior to put it into production.  This is just 
an attempt to help you get started.

Regards,


Jose Lerebours
954-559-7186
http://www.fpgroups.com



More information about the Filepro-list mailing list