When you insert a date field into a document template you need to set how it will look. For example, you may want it to be a simple date like ‘10/12/20‘, or you may want the date to look like ‘Thursday, 10 December 2020‘. If you don't add a date format switch to the end of your field, the date will be inserted like this: '2020-12-10T00:00:00+10:30' - which is not all that readable, so we really do strongly suggest that you format your date fields in your templates.
Using the date format switch
You can set how the date will look in your templates by using a Word date format switch at the end of the field. The date format switch is “\@” followed by the desired format in “quotes”:
Example {MERGEFIELD Date_dt \@ "dd MMMM yyyy"}
Other common date format switches
Some more examples of how you may want to format dates in your templates:
Examples "MMMM d, yyyy", results in "January 2, 1995" "MMMM dd, yyyy", results in "January 02, 1995" "MMM d, yyyy", results in "Jan 2, 1995" "dddd, MMMM d, yyyy", results in "Monday, January 2, 1995" "h:mm am/pm dddd, MMMM d", results in "10:00 am Monday, January 2"
Detailed formatting options
Below is a breakdown of the detailed formatting options.
Month (M)
The letter M must be uppercase to distinguish months from minutes.
M This format item displays the month as a number without a leading 0 (zero) for single-digit months. For example, July is 7.
MM This format item displays the month as a number with a leading 0 (zero) for single-digit months. For example, July is 07.
MMM This format item displays the month as a three-letter abbreviation. For example, July is Jul.
MMMM This format item displays the month as its full name.
Day (d)
The letter d displays the day of the month or the day of the week. The letter d can be either uppercase or lowercase.
d This format item displays the day of the week or month as a number without a leading 0 (zero) for single-digit days. For example, the sixth day of the month is displayed as 6.
dd This format item displays the day of the week or month as a number with a leading 0 (zero) for single-digit days. For example, the sixth day of the month is displayed as 06.
ddd This format item displays the day of the week or month as a three-letter abbreviation. For example, Tuesday is displayed as Tue.
dddd This format item displays the day of the week as its full name.
Year (y)
The letter y displays the year as two or four digits. The letter y can be either uppercase or lowercase.
yy This format item displays the year as two digits with a leading 0 (zero) for years 01 through 09. For example, 1999 is displayed as 99, and 2006 is displayed as 06.
yyyy This format item displays the year as four digits.
Comments
0 comments
Article is closed for comments.