# Creating a "field" in Word with an Excel formula



## cb73000 (Apr 8, 2004)

I want to create a field in a word document that shows yesterday's date. I do this in excel with the formula =now()-1, with appropriate date format settings for the specific cell. 

How can I make a similar field in Word? I'm looking to make it on a single line that isn't so much in a "box looking" type field.


----------



## Anne Troy (Feb 14, 1999)

http://www.addbalance.com/word/datefields2.htm


----------



## emin.gabrielyan (Sep 4, 2008)

Hello,

You can find here a doc file with field formulas for computing the previous date of any given input date:
http://switzernet.com/public/080904-word-field-date-calc/
http://unappel.ch/public/080904-word-field-date-calc/

Field formulas look as follows:








[doc]

Greetings,
Emin


----------



## emin.gabrielyan (Sep 4, 2008)

The example below validates previously presented MS Word field formulas by applying the calculations on numerous date values retrieved from an excel file [xls] by a merged doc file [doc]:

http://switzernet.com/public/080904-word-field-process-dates/
http://unappel.ch/public/080904-word-field-process-dates/

Greetings
--


----------



## emin.gabrielyan (Sep 4, 2008)

Hello,

Here are three compact formulas (improved and simpler) for computing the previous day of any given input date (aay=year, aam=month, aad=day):

year: bby =aay-and(aam=1,aad=1)

month: bbm =mod(aam-1+12-(aad=1),12)+1

day: bbd =if(aad>1,aad-1,if(bbm=2,if(mod(bby,4)=0,29,28),30+mod(bbm+(bbm>=8),2)))

These formulas are completely excel compatible. Joined is an excel file using exactly these formulas [xls]. An html page shows how the excel file operates without opening the excel [htm].

MS-Word field formulas look as follows:








[doc]

The detailed doc is available for more info [more].

Greetings,
Emin


----------



## emin.gabrielyan (Sep 4, 2008)

Hello,

In the joined version, the leap year calculation is accurate and follows the complete definition of leap years in Gregorian calendar [wiki].

The screenshot below creates the date of yesterday:








These formulas are Excel compatible [xls], [htm].

The screenshot below create the last date of the previous month:








The same formulas work also in an Excel file [xls], [htm]

More information is in the MS-Word doc file containing also the field formulas themeselves [more], [doc]. You need also the excel file with date samples for merging with the main DOC file [xls].

Regards
Emin


----------



## jimr381 (Jul 20, 2007)

Whoosh. I personally would insert a one cell Excel worksheet via the "Insert Microsoft Excel Worksheet" button on the standard toolbar. I then would turn off the borders and make the table in-line with the text and type your formula within it.


----------



## emin.gabrielyan (Sep 4, 2008)

Hi,
Could be an easier solution:








May I parse a bookmark variable into the excel sheet?
I need to interact with the excel sheet and provide an input data available with MS Word field codes.

Thanks
Emin


----------

