3 Replies Latest reply: May 15, 2014 9:53 AM by Nick Osdale-Popa RSS

    Calculate age from date of birth

    jb@sharp _

      I have Monarch Pro 9.01.


      I have a large file with thousands of people listed in which I need to create a calculated field that gives me each person's age at the beginning of a particular month.  For example, in October I need to know the age of the person as of October 1st.  I will receive a new file in November which I will be using the same model on and will need to change the calculated field to get the age as of November 1st.  I am sure it will be easy to update the calculated field every month but would like to get ideas on the easiest way to initially create the calculated field.




        • Calculate age from date of birth
          Data Kruncher

          Hi Jeff,


          I'd use Monarch's Age function to handle that, perhaps in conjunction with a runtime paramter that would supply you with the comparison date, or the month number. If your monthly report file has the month (and year) in the filename, you could even use the File() function and some other string functions to extract the month from the filename.


          For instance, you could get month number 11 and year 2007 out of "My File for Nov 2007.txt" if you can guarantee that the month and year always appear in the same position in the filename.


          You'd use a lookup field to get 11 for Nov.


          Then use that those fields in the Age function:

          [font="courier"]Age(BirthDate,CtoD(Trim(Str(LookupMonthNumber))"/1/"trim(FileNameYear),"m/d/y"),1)  /font[/quote]where FileNameYear is a string field extracted from the filename.


          Would something like that do the job for you?



          • Calculate age from date of birth
            jb@sharp _

            It turned out to be very easy.  I didn't know there was an age function.  Might have been a good idea to do a little research first.  The calculated field using the field from the file called DOB was simply:




            This gave me the age as of October 1st.  I will simply need to change the enddate based on the month of the file I am using.


            Thanks for your help.

            • Calculate age from date of birth
              Nick Osdale-Popa

              If the file itself has the date you could trap that and not have to worry about changing the date yourself.