The DateTime Field option of DocumentsCorePack (DCP) allows you to perform basic calculations on dates and times. This article describes the syntax that can be used for those calculations.
- The basic syntax: Fields from Dynamics are enclosed by “<<” and “>>” when you insert them from the tree view.
- The difference between two dates can be subtracted by using a “–”
Figure 2: Difference between two dates
- Functions on a date can be executed by adding a dot “.” and the function name including the necessary parameters.
Figure 3: Function with parameters
- Supported functions and operators:
Operator Name |
Sign | Example |
Difference | – | <<duedate>> – DATETIME()
For example, calculate an offer with a due date minus today´s date. |
Figure 4: Operator table
Function | Description | Examples |
Add(value, unit) | Adds a numeric value to the current date. The first parameter represents the numeric value that should be added. The second parameter represents the unit. Parameters for units are either: year, month, weeks, days, hours, minutes, seconds, milliseconds |
<<createdon>>.Add(10,year) |
Subtract(value, unit) | Subtracts a numeric value from the current date. The first parameter represents the numeric value that should be subtracted. The second parameter represents the unit. Parameters for units are either: year, month, weeks, days, hours, minutes, seconds, milliseconds |
<<createdon>>.Subtract(10,year) |
Addbusinessdays(value) | Adds a certain amount of days to the current date. Weekends (Saturday and Sunday) are excluded from this calculation. |
<<createdon> >.Addbusinessdays(10) |
Round(unit, direction) | Round allows you to modify a time value to the next or previous quarter, half or full hour. The first parameter can display a quarter, half or full hour. The second parameter represents the direction. (up/down) |
<<createdon>>.Round(quarter,up) <<createdon>>.Round(half,down) <<createdon>>.Round(full) |
DATETIME() | This function returns the current date and can be used as a field paired with any of the above functions. | DATETIME().Add(5,days) |
Figure 5: Function table
Please note: You cannot join different parameters. If you would like to add days and months, please always use the lowest unit for your chosen parameter. For example, 1 Month and 15 Days would be 45 Days.
That´s it! We appreciate your feedback. Please share your thoughts by sending an email to support@mscrm-addons.com.