Field codes

G

gwh

Version: 2004
Operating System: Mac OS X 10.4 (Tiger)
Processor: intel

Hi everyone,

I've used a field code to dynamically update a date in a document, but I've broken it up so that the day is one field and the month and year is in the other field, like this:

22nd day of April, 2008.

The problem is that the "nd" after 22 will need to change depending on the day of the month, ie. there would have to be "st" after 21 or "rd" after 23 etc.

Does someone know how I can get this part of the date to update/change according to the day dynamically? Would I need VBA to do this or can it be done with Word's fields?

Thanks for any help offered.
 
S

Shawn Larson [MSFT]

To get the Œending¹ on the numbers that you want Œ3rd¹, Œ5th¹, Œ22nd¹, etc.
and to get this information as the result of a field ­ so that it will
automatically update ­ you will need to use the ŒFormat¹ field switch - \*.
Now the catch is the format field switch cannot be used with a DATE or TIME
field, but I can provide a workaround to get the results you want. The key
is to use the QUOTE field in conjunction with the DATE field. The result of
a QUOTE field is text, so the result of this example:

{QUOTE ³This is a string of text!²} is This is a string of text!

Pretty worthless, but the power of the QUOTE field is using it in
conjunction with other fields. Remember, the result of a QUOTE field is
text. Once you have that text, you can you use other field switches to
manipulate the display of the result.

We need to look at the DATE field first and set it up to display just the
date Œ21¹, Œ22¹, Œ23¹, etc. The following field syntax will give you that
result:

{DATE \@ ³dd²} --- this will display just the date number

The ³\@² is the Œdate-time picture¹ formatting switch, which is used to
format how the result of a DATE field will display.

The format you want is called Œordinal¹. Below is an example using fields
to get result you want. Since this example uses the DATE field, when it is
updated, it will reflect the current date:

{ QUOTE { DATE \@ ³dd²} \ * ordinal}

I¹ve included a more complicated example, which, when updated, gives a
result like ³23rd day of April, 2008²:

{ QUOTE { QUOTE { DATE \@ ³dd²} \ * ordinal}{QUOTE ³ day of² {DATE \@
³MMMM, yyyy²}}}

I think I¹ll post this as is for right now. If you need any more
clarification, have questions, or need more information, please feel free to
reply to this post and I¹ll help you as much as I can.

HTH,
Shawn Larson
Mac Word Test
Microsoft MacBU
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top