• calculate age from date of birth in Word 2003

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » calculate age from date of birth in Word 2003

    Author
    Topic
    #459802

    Is it possible to calculate a person’s age from their date of birth in Microsoft Word 2003?

    I know this can be done in Access and Excel, but can it be done in Word?

    Tom

    Viewing 0 reply threads
    Author
    Replies
    • #1160307

      Is it possible to calculate a person’s age from their date of birth in Microsoft Word 2003?

      I know this can be done in Access and Excel, but can it be done in Word?

      Tom

      Hi Tom,

      To see how to do this and just about everything else you might want to do with dates in Word using field coding (not macros), check out my Word Date Calculation Tutorial in [post=”249902″]Post 249902[/post]. In particular, look at the item titled ‘Interactively Calculate A Person’s Age’. Do read the document’s introductory material.

      It’s also possible to do the same sort of thing with a macro.

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

      • #1160344

        Hi Tom,

        To see how to do this and just about everything else you might want to do with dates in Word using field coding (not macros), check out my Word Date Calculation Tutorial in [post=”249902″]Post 249902[/post]. In particular, look at the item titled ‘Interactively Calculate A Person’s Age’. Do read the document’s introductory material.

        It’s also possible to do the same sort of thing with a macro.

        Macropod
        Thanks! I downloaded the file and will have a look at it.

        I’m not wild about using a Macro, because the of the potential intrusion by viruses.

        Tom

        • #1160372

          An example of what I want to do is calculate the age, using the date of birth July 29, 1937, or 7/29/1937

          So I plugged in the following
          {QUOTE
          {ASK StartDate “What is the starting date, in dd/mm/yyyy format, please?” d 13/05/2009″}}{ASK Delay “What is the number of days +/- offset?”}
          SET a{=INT((14-{ StartDate @M})/12)}}
          {SET b{={StartDate @} yyyy}+4800-a}} … plus the rest of whatever is in the code

          All I end up getting is the following:

          If the starting date is Monday, 1 January 2001 and the offset is 0 day, then the new date is Tuesday, 6 January 2009.

          How do I fix this?

          Thanks.

          Tom

          • #1160377

            An example of what I want to do is calculate the age, using the date of birth July 29, 1937, or 7/29/1937
            All I end up getting is the following:
            If the starting date is Monday, 1 January 2001 and the offset is 0 day, then the new date is Tuesday, 6 January 2009
            How do I fix this?

            Thanks.
            Tom

            Hi Tom,

            That’s not the field code I pointed you to! It looks like the code from ‘Interactively Calculate A Past Or Future Date’, to which you’ve added a default starting date of 13/05/2009. It’s hardly surprising you didn’t get the result you’re after.

            All you need to do is to copy the *correct* field code into your document, select it and press F9. For the ‘July 29, 1937’ input, I get:
            If your Date of Birth was 29 July 1937, then your age is 71 Years, 9 Months and 15 Days.

            Cheers,
            Paul Edstein
            [Fmr MS MVP - Word]

          • #1160379

            That’s obviously not the “Interactively Calculate A Person’s Age” example.

            I have attached a sample document that has been set up for US date format.

            • #1160404

              Thanks for the feedback.

              I apologize. Very sorry…I got on the wrong code.

              When I highlight the code and press F9 I get the Input Box, “What is the birth date?”
              I enter the birth date and press OK…then I’m back in the code.
              Next, I press F9, I get If your Date of Birth was 29 July 1937, then your age is 71 Years, 9 Months and 15 Days.

              I guess that’s the way it’s supposed to work.

              I’m getting closer. What I need to do now is work with the code, so that I end up getting only the age part, i.e. 71 Years, 9 Months and 15 Days
              This works nicely for children. Probably for adults I will need to get only the years, i.e. 71 years

              Tom

            • #1160406

              You don’t need to display field codes except if you want to edit them.
              Simply click in the field and press F9 to update it.

              I have attached a version that displays the age in years only.

            • #1160439

              Is there a way to make this conditional, so that…
              1. if a person is under the age of 3, the age will show as Years, Months, Days
              2. if a person is 3 years of age or older, the age will show as Years only

              Or does this have to be 2 separate scripts?

              Tom

            • #1160448

              If you study the field codes, you’ll see that you can add an IF field to check the age. See the attached version.

            • #1160478

              If you study the field codes, you’ll see that you can add an IF field to check the age. See the attached version.

              This is looking really good.

              Is there a reason it won’t accept a date of birth before 1900?
              Entering a value in 1899 gives a result of 2009 years.

              Tom

            • #1160481

              This is looking really good.

              Is there a reason it won’t accept a date of birth before 1900?
              Entering a value in 1899 gives a result of 2009 years.

              Tom

              Actually, I should have said it won’t accept a date prior to 1901. A date in 1900 also gives 2009 years.

              Tom

            • #1160482

              As macropod explains in his document, the field codes only work correctly for dates between January 1, 1901 and December 31, 4095. To make them work with dates outside this range, they need to be modified considerably. See the section “Working With Dates Before 1 Jan 1901 Or After 31 Dec 4095” in macropod’s document.

            • #1160495

              As macropod explains in his document, the field codes only work correctly for dates between January 1, 1901 and December 31, 4095. To make them work with dates outside this range, they need to be modified considerably. See the section “Working With Dates Before 1 Jan 1901 Or After 31 Dec 4095” in macropod’s document.

              Missed that piece. It’s not worth turning modification hoops to do it, as the need will be rare indeed.

              Tom

            • #1160496

              Missed that piece. It’s not worth turning modification hoops to do it, as the need will be rare indeed.

              Tom

              Indeed! Just how many people do you need to work out the age for who were born before 1/1/1901?

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #1160527

              Indeed! Just how many people do you need to work out the age for who were born before 1/1/1901?

              Paul
              Many thanks for referring this valuable resource to me!

              The situation in question has a couple of people over 100 years of age, but nobody beyond 107. I’d also be surprised if I were to be around long enough to hit the year 4095…unless I was related to Mel Brooks’ 10,000 year old man!

              Cheers!

              Tom

            • #1160615

              Paul
              Many thanks for referring this valuable resource to me!

              The situation in question has a couple of people over 100 years of age, but nobody beyond 107. I’d also be surprised if I were to be around long enough to hit the year 4095…unless I was related to Mel Brooks’ 10,000 year old man!

              Cheers!

              Tom

              Hi Tom,

              I’m glad to hear your appointment calendar isn’t full till 4095 …

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #1160659

              Here’s my puzzle, with a bit of a snag.

              Access is on System One. A complete database that includes a number of persons with names, addresses, date of birth etc.

              Access is not on System Two and, for complicated reasons, it’s not wanted on that system. However, there is one report from the Access file that System Two wants to use.
              It is largely more like a pre-printed form on which Access grabs the person’s first name, last name and birth date, calculates the age of the person, fills those 4 things in on the report and prints it.

              The report could be pre-printed for use in Word.

              System two wants to take the pre-printed form, have mail merge fields for the four fields (the one field code calculating the age, which is why I made this post initially), grab the data for the person desired from the Access file and print.

              Is there a way to connect to Access from Word, without having Access on System Two?

              Tom

            • #1160870

              1) On system 2:
              Start Word.
              Select Tools | Options…
              Activate the General tab.
              Make sure that the check box “Confirm conversion at Open” is ticked.
              Click OK.
              Open the merge document.
              Activate the Mail Merge task pane and go to step 3.
              If your document is already connected to the database, click Select another list, otherwise click Browse…
              When you select the Access database, Word will prompt you to choose a method to connect to the database. Do *not* choose the DDE method – this requires Access to be present. The other methods (OLE DB and ODBC) should work OK even if Access has not been installed.

              2) Why not calculate the age in Access instead of in Word?

            • #1160936

              1) On system 2:
              Start Word.
              Select Tools | Options…
              Activate the General tab.
              Make sure that the check box “Confirm conversion at Open” is ticked.
              Click OK.
              Open the merge document.
              Activate the Mail Merge task pane and go to step 3.
              If your document is already connected to the database, click Select another list, otherwise click Browse…
              When you select the Access database, Word will prompt you to choose a method to connect to the database. Do *not* choose the DDE method – this requires Access to be present. The other methods (OLE DB and ODBC) should work OK even if Access has not been installed.

              2) Why not calculate the age in Access instead of in Word?

              Hans
              I agree with you entirely. By far the best solution is to get Access on System 2. (it’s complicated)

              Tom

            • #1160943

              If you create a query in the database that includes the age calculation, this could be used as data source for the mail merge in Word on system 2 even if Access isn’t installed there. It would avoid the use of macropod’s clever but also rather complicated field codes.

    Viewing 0 reply threads
    Reply To: calculate age from date of birth in Word 2003

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: