Mitech Preloader

IncrementDate

User Reference

IncrementDate

Increment a date by a certain number of days, months or years.

 

Command structure:

«IncrementDate(DateOfBirth,25, "y")»

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

 

Further examples:

Tomorrow: «IncrementDate(Today(),1,"d")» i.e. add 1 day to today’s date.

Yesterday: «IncrementDate(Today(),-1,"d")» i.e. subtract 1 day from today’s date.

 

Formatting the incremented dates:

Yesterday’s date: «FormatDate(IncrementDate(Today(),-1,’d’),’MMMMM d yyyy’)»

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”. Not to be confused with “weeks”.

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')».

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.

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')».

 


Related articles:

FormatDate