a!subtractDateTime( startDateTime, years, months, days, hours, minutes, seconds, useProcessCalendar, processCalendarName )
Subtracts the specified increments of time from the startDateTime and returns a date and time value. You can select a process calendar to ensure the return value falls within the specified working days and time.
Keyword | Type | Description |
---|---|---|
|
Date and Time |
The starting Date and Time value. Use the datetime() function to convert a given date and time into a serial number that holds the Date and Time data type. This parameter is required. |
|
Number (Integer) |
The number of years to subtract from the start value. |
|
Number (Integer) |
The number of months to subtract from the start value. |
|
Number (Integer) |
The number of days to subtract from the start value. |
|
Number (Integer) |
The number of hours to subtract from the start value. |
|
Number (Integer) |
The number of minutes to subtract from the start value. |
|
Number (Integer) |
The number of seconds to subtract from the start value. |
|
Boolean |
Determines if a process calendar is used to calculate the result. The returned value will fall within the work time defined in the calendar. Default is false. |
|
Text |
The name of the process calendar to use. If useProcessCalendar is true and this parameter is not specified, the default process calendar is used. This parameter is case-sensitive. |
Date and Time
The startDateTime parameter can accept values of type Text, Date, Date and Time, Integer since the epoch, Decimal since the epoch, and Array types. Time values are not supported.
If you use a Date data type, the value will be automatically cast to a Date and Time data type. When the value is cast to Date and Time, the time component will be 12:00 AM GMT unless you've specified a process calendar. If you specified a process calendar, then the time component will be 12:00 AM in the calendar's specific timezone.
If multiple values are passed to the startDateTime parameter, or the value is type Array, the function will return a Date and Time array.
Process calendars are configured by your system administrators to determine your environment's working days and hours. Consider setting the useProcessCalendar parameter to true when you want your calculation to return a date and time within the specified working hours. The return value will be in the calendar's specified timezone.
If you have multiple calendars configured, you can use the processCalendarName parameter to specify the correct calendar configuration to use in your calculation.
Learn how to configure process calendar settings.
You can use a combination of years, months, days, hours, minutes, or seconds in your calculation. The calculation will be performed on the largest unit of time (years) to the smallest (seconds). If any of these parameters are 0
or null, it will be ignored in the calculation.
Note: You cannot add negative values in any of these parameters. For example, year: -2
will return an error.
The total amount of time added to the start date cannot exceed 100 years.
You cannot use this function in a process event, like a Timer Event or Start Event.
Instead, you should use the calendar functions caladddays() or caladdhours() to add increments of time to a start date in a process event.
Copy and paste the following examples into an Appian Expression Editor to experiment with this function.
1
2
3
4
5
6
7
8
a!subtractDateTime(
startDateTime: datetime(2001, 1, 1, 0, 0, 0),
months: 1,
days: 1,
hours: 1,
minutes: 1,
seconds: 1
)
Returns 11/29/2000 10:58 PM GMT+00:00
1
2
3
4
5
6
7
8
a!subtractDateTime(
startDateTime: {datetime(2000,1,1,0,0,0),datetime(2001,1,1,0,0,0)},
months: 1,
days: 1,
hours: 1,
minutes: 1,
seconds: 1,
)
Returns 11/29/1999 10:58 PM GMT+00:00; 11/29/2000 10:58 PM GMT+00:00
In this example, there are multiple process calendars, so we've specified the default process calendar to use in our calculation. This calendar has working hours defined as weekdays only from 9am to 5pm GMT.
1
2
3
4
5
6
a!addDateTime(
startDateTime: datetime(2000,2,1,0,0,0), /*Tuesday*/
days: 5,
useProcessCalendar: true,
processCalendarName: "Default Calendar"
)
Returns 1/25/2000 12:00 AM GMT+00:00
Feature | Compatibility | Note |
---|---|---|
Portals | Compatible | |
Offline Mobile | Compatible | |
Sync-Time Custom Record Fields | Compatible | Can be used to create a custom record field that only evaluates at sync time. |
Real-Time Custom Record Fields | Incompatible | |
Process Reports | Incompatible | You cannot use this function to configure a process report. |
Process Events | Incompatible | You cannot use this function to configure a process event node, such as a start event or timer event. |
a!subtractDateTime() Function