Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Age Calculation with Fields.

Age Calculation with Fields

Written by Allen Wyatt (last updated April 1, 2019)
This tip applies to Word 97, 2000, 2002, and 2003


3

If you desire, you can use fields to calculate an age. For instance, the field could calculate the number of years between some base date and today's date. The following compound field will do the trick:

{ = INT({ DATE \@ "yyyy" } + { DATE \@ "M" } / 12 +
{ DATE \@ "d" } / 365.25 - YYYYb - Mb / 12 - Db / 365.25) }

As those who are familiar with fields know, each of the braces in this sample represents a new field. In addition, you should replace the YYYYb, Mb, and Db placeholders with the year, month, and day of month for the base date. For instance, if your birthday were 21 June 1959, then you would replace YYYYb with 1959, replace Mb with 6, and Db with 21. When you then calculate the field (by selecting it and pressing F9), it is replaced with a number representing the number of years between the base date and today.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1008) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Age Calculation with Fields.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Seeing Full File Names in the Files Menu

Wouldn't it be great if you could look at the files in the MRU list and see the full path and file names? Excel condenses ...

Discover More

Protecting Conditional Formatting

When you apply conditional formatting to the cells in your worksheet, those rules can seem a bit fragile at times. For ...

Discover More

Reusing a Bookmark

Bookmarks in Word are just like bookmarks used in paper books, any given bookmark may be reused to mark a new location. ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

More WordTips (menu)

Inserting the Name of the Last Person to Save the Document

Who saved the document the last time? Word keeps track of that information, and you can insert the person's name into the ...

Discover More

Auto-incrementing Form Fields

Templates are a great way to create new documents because they act as intricate patterns to what those new documents ...

Discover More

Copying and Pasting Field Codes

Want to copy a field code and paste it in some other Windows program? This can be trickier than it sounds. Here's the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 1 + 1?

2023-08-09 12:35:46

Claude Albertario

Hi,
Reviewing https://wordribbon.tips.net/T009541_Age_Calculation_with_Fields.html I am wondering how to place this age calc filed in a form with fillable fields, where the YYYYb, Mb, and Db placeholders change every time the form field get filled?


2016-06-25 16:54:47

v mehta

the below code for file 123.doc, with PFNAME and PLNAME being Barack Obama, gives me, 123BarackObama.doc

Public Sub UpdateKImartin()

Dim name As String
Dim source As String
Dim path As String
'extract the name from the bookmark

source = ActiveDocument.FullName


name = ActiveDocument.Bookmarks("PFNAME").Range.Text
name2 = ActiveDocument.Bookmarks("PLNAME").Range.Text
'Save the doc with the new name

ActiveDocument.SaveAs _
Left(ActiveDocument.FullName, Len(ActiveDocument.FullName) - 4) & _
name2 & "_" & name & Right(ActiveDocument.FullName, 4)

ActiveDocument.Close wdSaveChanges
Kill source

End Sub


I want BarackObama123.doc. how do i achieve this ?


2014-08-11 18:25:01

novice

thanks, it was great if you could upload a document of this form


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.