The FormatDate and IncrementDate Functions

by Peter on April 14, 2011

in User Reference


Date data elements can be formatted according to the format patterns defined for the .NET framework. For example:

<<FormatDate(dateofengagement,"dd MMM yyyy","af")>>
<<FormatDate(dateofdismissal,"d MMMM, yyyy")>>
<<FormatDate(dateofSignature,"MMMM o yyyy")>>
<<FormatDate(dateofSignature,"dddd MMMM o yyyy")>>

These examples would result in something like, respectively:
07 Februarie 2013
7 February, 2013
February 7th 2013
Thursday February 7th 2013

Except for the Afrikaans example, the other results are in English, not because the default language is English, but because the default is either the Word version’s language or else the language chosen by the user in the XpressDox Settings.

The ‘af’ above will cause the month to be output in Afrikaans, because XpressDox supports the use of any ISO 639-1 language code in the FormatDate function. These codes are defined in the second column in ISO 639-1.

If you need the ‘th’ in the date February 29th 2008 to be superscripted in the final result, then another technique would be used:
<<FormatDate(SignatureDate,"MMMM d")>><<OrdinalSuffix(FormatDate(SignatureDate,"d"))>> <<FormatDate(SignatureDate,"yyyy")>>
where the <<OrdinalSuffix(...)>> is superscripted in the template.


This function will take a date and increment a certain number of days, months or years to the date, and return the resulting date in a format which can be printed as is, or can be passed to the FormatDate function:

<<IncrementDate(DateOfBirth,25, "y")>>

The above will add 25 years to the value in the data element ‘DateOfBirth’.

Tomorrow is: <<IncrementDate(Today(),1, "d")>>

This will add 1 day to today’s date.

Now see that the increment units can be negative, and that you can pass the result of one function to another:

About six months ago (on <<FormatDate(IncrementDate(Today(),-6, "m"),"d MMMM yyyy")>>) the weather was completely different.

Working Days

With Version 5 of XpressDox a new “units” specifier was added: “w”, meaning “working days”.

Saturdays and Sundays are always considered non-working days. For example, if two working days are added to a date which is a Friday, then the result is the following Tuesday.

Extra non-working days can be added either by specifying them in the function call itself, or by configuring them in the “Other Settings” tab of the XpressDox configuration. For example:

The court appearance will be in 10 court days from now, i.e. <<FormatDate(IncrementDate(Today(),10,'w','2013-01-01,2013-05-01,2013-12-25'),'MMMM d, yyyy')>>.

The non-working day dates provided in the function call do not need to be hard-coded. For example, if there is another system available at the site where the template is run and this system maintains a reliable list of non-working days, and this system is accessible via COM or .NET, then using the XpressDox Interact with External Programs capability, the following would be possible:

The court appearance will be in 10 court days from now, i.e. <<FormatDate(IncrementDate(Today(),10,'w',GetObjectValue('o2Smart.Accounting:Settings.GetPublicHolidays')),'MMMM d, yyyy')>>.

If the non-working days are omitted from the function call (<<FormatDate(IncrementDate(Today(),10,'w'),'MMMM d, yyyy')>>) then the non-working days are taken from the XpressDox configuration, if they have been specified and apply to the template being executed. In any case, Saturdays and Sundays are always regarded as non-working days.