DateAdd
This function will be deprecated in a future release, so use it with caution.
However, it is still supported for existing expressions, so it has not been removed from the application. Editing an expression using this function can cause an error message to appear.
Instead of this function, use AddYears, AddQuarters, AddMonths, AddWeeks, AddDays, AddHours, AddMinutes, or AddSeconds.
Returns a local date and/or time obtained by adding the value of the interval parameter to the starting date and/or time. This function takes into account the units (defined by the datePart parameter) for the interval.
Syntax
DateAdd(datePart, interval, startingDateTime)
Enabled For
For a description of the business object categories, see Notes on "Enabled For".
Business Object Category | Yes/No |
---|---|
Business Rules: Before-Save Rules | Yes |
Business Rules: Calculation Rules (After Save, with or without Also Recalculate on Load) | Yes |
Business Rules: Calculation Rules (Before Save or Always, without Also Recalculate On Load) | Yes |
Business Rules: Calculation Rules (Before Save or Always, with Recalculate On Load) | Yes |
Business Rules: Editing Rules | Yes |
Business Rules: Initialization Rules | Yes |
Business Rules: Read Only Rules | Yes |
Business Rules: Required Rules | Yes |
Business Rules: Validation Rules | Yes |
Client Expressions | Yes |
Object Permissions | Yes |
Services | Yes |
LDAP | Yes |
Mobile | Yes |
Quick Actions (except UI Quick Actions) | Yes |
UI Quick Actions | Yes |
Reports | Yes |
Search/Dashboard without field references | Yes |
Search/Dashboard with field references | Yes |
Parameters
datePart |
The interval type. Must be surrounded by quotes (" "). The following interval types are supported: millisecond second minute hour day |
interval | A numeric value that is a type of the part specified in the datePart parameter. |
startingDateTime | The starting date and time. |
Return Value
DateTime value.
If the application has to display the return value, it implicitly converts it to text, thereby allowing the display format to change depending on your culture code. See Available Languages and Cultures for a list of the culture codes used by Service Manager.
Example
$(DateAdd("day",-90,CurrentDateTime()))
The example above shows how to retrieve incidents from the past 90 days in conjunction with the CurrentDateTime() function.
DateAdd() Example