Inserting Dates and Times
There are several ways to insert dates and times into a Word document. The date and time that you insert can be based on one of the following.
- The current date and time
- The date and time when your document was created
- The date and time when your document was last saved
- The date and time when your document was last printed
- An expression that Word treats as a date or time
In addition, the date and time that appear in a document can be calculated from any of the dates and times just listed.
Inserting the Current Date and Time
One way to insert the current date is to place your cursor at the place where you want to insert the current date and press Alt+Shift+D, which inserts a DATE field with the default date formatting that corresponds to the regional settings defined for you in Control Panel. Similarly, you can insert the current time by placing your cursor at the place where you want to insert the current time and pressing Alt+Shift+T, which inserts a TIME field.
You can also insert a DATE field using the user interface. To do so, on the Insert tab in the Text group, click Date and Time (when a header or footer is selected, click Date and Time on the Design tab). In the Date and Time dialog box that opens, you can select a formatting option, and Word will add the applicable switch for the selected formatting option. If you clear the Update automatically check box, Word will transform the field inserted into text for the current date and time. You can also insert the current date and time by opening the Field dialog box and selecting the DATE or TIME field.
The DATE field can be updated by placing your cursor within it or by selecting the field and then pressing F9. The DATE field is also updated automatically whenever you open the document. You can lock a DATE field (or any other field) so that it will not be updated again by placing your cursor within the field and pressing Ctrl+3 or Ctrl+F11. To unlock a field so that it can be updated, place your cursor within the field and press Ctrl+4 or Ctrl+Shift+F11.
Before you distribute a document containing a DATE or TIME field, consider that the date and time displayed in the document will be changed automatically every time that the document is opened unless you lock the field.
Inserting the Date and Time When a Document Was Created
The date and time when a document was created, which are defined as the date and time when the document was first saved with its current name, can be shown in the document by inserting a CREATEDATE field. To insert a CREATEDATE field, on the Insert tab in the Text group, click Quick Parts and then click Field. In the Field dialog box that opens, in the Field names box, select CREATEDATE. If you do not select a format in the Date formats box, Word will insert the date and time with the default date and time formatting that corresponds to the regional settings defined for you in Control Panel.
You can also insert a CREATEDATE field manually by typing CREATEDATE, selecting the code that you just typed, and pressing Ctrl+F9, which adds the special curly brackets that mark a field code. Then press F9 to update the data in the field, hide the field code, and display the date and time.
Inserting the Date and Time When a Document Was Last Saved
The date and time when a document was last saved can be shown in the document by inserting a SAVEDATE field. To insert a SAVEDATE field, follow the steps to open the Field dialog box in the previous section. Then, in the Field dialog box, in the Field names box, select SAVEDATE. If you do not select a format in the Date formats box, Word will insert the date and time with the default date and time formatting that corresponds to the regional settings defined for you in Control Panel.
You can also insert a SAVEDATE field manually by typing SAVEDATE, selecting the code that you just typed, and pressing Ctrl+F9, which adds the special curly brackets that mark a field code. Then press F9 to update the data in the field, hide the field code, and display the date and time.
Inserting the Date and Time When a Document Was Last Printed
The date and time when a document was last printed can be shown in the document by inserting a PRINTDATE field. To insert a PRINTDATE field, follow the steps to open the Field dialog box in Inserting the Date and Time When a Document Was Created. Then, in the Field dialog box, in the Field names box, select PRINTDATE. If you do not select a format in the Date formats box, Word will insert the date and time with the default date and time formatting that corresponds to the regional settings defined for you in Control Panel.
You can also insert a PRINTDATE field manually by typing PRINTDATE, selecting the code that you just typed, and pressing Ctrl+F9, which adds the special curly brackets that mark a field code. Then press F9 to update the data in the field, hide the field code, and display the date and time.
Inserting an Expression That Word Treats as a Date or Time
Word can recognize text typed in specific formats as a date or a time. When Word recognizes expressions as dates or times, you can use those expressions to do the following:
- Create a list of such expressions and have Word sort the list of dates and/or times in ascending or descending order.
- Enter an unordered series of such expressions in a column in a table and have Word sort the rows in the table in ascending or descending order according to the dates and/or times entered.
- Bookmark such an expression in one place in your document, create a cross-reference to the bookmark in another place in your document, and have Word show the bookmarked date and/or time in a different format using the Date-Time format switch (\@).
- Insert a QUOTE field containing an expression that Word treats as a date or time and have Word show the date and/or time with any one of many possible formats using the Date-Time format switch (\@).
In all four of these scenarios it is useful to know something about the expressions that Word treats as a date or time in order to avoid obtaining unexpected results.
A complete date consists of a number that indicates the day in the month in the range from 1 to 28, 29, 30, or 31, depending on the month, a number in the range from 1 to 12 that indicates the month or its name or its three-letter abbreviation, and a number that indicates the year. The parts of the date included in the expression must be separated by a space, a slash (/), or a hyphen (-). If Word can identify at least two of the parts as parts of a date, it will treat the expression as a date and set the remaining part equal to the applicable default. The following are some examples:
- "11/22/2007"
- "22-11-2007"
- "Jun 4 45"
- "4 June 45"
- "31/5"
- "5-31"
- "Sep 0"
In the last example the month specified is clearly September, the number 0 is interpreted as the year 2000, and the day of the month will be interpreted as the 1st of the month (the default value), since the day of the month is not specified. It should be mentioned here that Word does not recognize literal expressions containing a year before 1901 as a date.
Note that it is not advisable to use two numbers that are equal to 12 or less to indicate the day of the month and the month in a date expression, because the number that represents the month will be selected according to the regional settings defined in Control Panel on the local computer. Thus, the same set of numbers, for example, 6/4, will be interpreted as June 4 or April 6, depending on the regional settings, and the text in your document may be different on different computers.
A complete time consists of one number in the range from 0 to 23 that indicates the hour in the day and two numbers in the range from 0 to 59 that indicate the numbers of minutes and seconds. The parts of the time included in the expression must be separated by a colon (:).
- "6:30:45"
- "6:30"
- "18:30"
- "20:0:0"
- "20:0"
When you insert a QUOTE field with an expression that Word treats as a date or time, you can instruct Word to show the date and/or time in your document with any one of many possible formats. This can be useful, for example, when you want the dates in your document to be formatted according to the regional settings defined by each user who reads your document, or you want Word to automatically indicate the day of the week for a specific date or the 12-hour-clock time for a 24-hour-clock time.
To insert a QUOTE field, follow the steps to open the Field dialog box for your version of Word in Inserting the Date and Time When a Document Was Created. Then, in the Field dialog box, in the Field names box, select QUOTE, and in the Literal text box, type an expression that Word treats as a date or time within quotation marks ("").
When only a date is specified, the default time is 12:00:00 AM. When only a time is specified, the default date is the current date.If you do not select a format in the Date formats box, Word will insert the date and time with the default date and time formatting that corresponds to the regional settings defined for you in Control Panel.
You can also insert a QUOTE field manually by typing QUOTE followed by the date and/or expression in quotation marks and an optional Date-Time format switch (\@), selecting the code that you just typed, and pressing Ctrl+F9, which adds the special curly brackets that mark a field code. Then press F9 to update the data in the field, hide the field code, and display the date and time.
After you create a QUOTE field, you can use the information in the next section to modify the Date-Time format switch (\@). For example, { QUOTE "Sep-11-1" \@ "dddd" } will remind us that 9/11 was on a Tuesday. You can save this field code as an AutoText entry, insert it into a document, and change the date to show the day of the week of any date without running another application or looking the date up on a calendar.
Modifying the Appearance of Field Results
Word provides several switches for modifying the appearance of the dates and times produced by fields. If your field does not contain a Date-Time format switch (\@), Word will use the default date and time formatting that corresponds to the regional settings defined for you in Control Panel. To manually edit a field and to add or modify switches, right-click within the field, and then click Edit Field. The value following the optional Date-Time format switch (\@) uses letter codes to specify the order and formatting of the day (d), month (M), year (y), hours (h), minutes (m), and seconds (s) in the date and time displayed. You can also include a code that displays AM or PM, punctuation, and spaces, as well as other text that is enclosed in a pair of single quotation marks. The following table lists the codes that can be used with the Date-Time format switch (\@).
Time Unit | Code | Description |
---|---|---|
Day | ||
d | Displays the day of the month as a number without a leading 0 for 1 through 9. | |
dd | Displays the day of the month as a number with a leading 0 for 1 through 9, which are displayed as 01 through 09. | |
ddd | Displays the day of the week as a three-letter abbreviation, for example, Sun. | |
dddd | Displays the fully spelled out name of the day of the week. | |
Month | ||
M | Displays the month as a number without a leading 0 for months 1 through 9. | |
MM | Displays the month as a number with a leading 0 for 1 through 9, which are displayed as 01 through 09. | |
MMM | Displays the month as a three-letter abbreviation, for example, Jan. | |
MMMM | Displays the fully spelled out name of the month. | |
Year | ||
yy | Displays the last two digits of the year. | |
yyyy | Displays the four digits of the year. | |
Hour | ||
h | Displays the hour without a leading 0 for hours 1 through 9. | |
hh | Displays the hour as a number with a leading 0 for 1 through 9, which are displayed as 01 through 09. | |
Minutes | ||
m | Displays the number of minutes without a leading 0 for hours 1 through 9. | |
mm | Displays the number of minutes with a leading 0 for 1 through 9, which are displayed as 01 through 09. | |
Seconds | ||
s | Displays the number of seconds without a leading 0 for hours 1 through 9. | |
ss | Displays the number of seconds with a leading 0 for 1 through 9, which are displayed as 01 through 09. | |
12 Hour period | ||
am/pm | Displays AM after a time that is within the first 12 hours of the day or PM after a time that is within the second 12 hours of the day. The symbols displayed are specified by the regional settings in Control Panel. |
The codes d, y, h, s, and am/pm can be uppercase or lowercase. The uppercase M must be used to display the month, and the lowercase m must be used to display the number of minutes.
In addition to these codes, you can insert spaces and punctuation, such as colons (:), commas (,), hyphens (-), asterisks (*), and brackets ([]), as well as other text that is enclosed in a pair of single quotation marks ('). For example, { DATE \@ "hh:mm am/pm 'on' dddd, MMM. d, yyyy" } would have displayed 11:20 AM on Tuesday, Dec. 1, 2009 at that time on that day.
The \* Ordinal format switch, which adds the appropriate suffix (st, nd, rd, or th) to a number, can be used, for example, with the day of the month. The \* CardText format switch displays numbers in words. The \* Caps, \* FirstCap, \* Upper, and \* Lower format switches control capitalization. The \* Charformat switch applies the formatting of the first letter of the field name to the entire result. The \* MERGEFORMAT switch applies the formatting of the previous result to the updated result. This switch is added automatically when you insert a field using the Field dialog box unless you clear the Preserve formatting during updates check box.
In addition, you can use the \h switch to display the date according to a supported lunar calendar, such as the Hebrew or Islamic calendar, the \l switch to display the date with the last format selected using the Date and Time command, and the \s switch to display the date according to the Saka Era calendar (if supported).
More Information
For more information about the syntax of field codes, see the Microsoft help topic Insert and Format Field Codes in Word 2010. For more information about date calculations and formatting, download DateCalc.zip.