FunctionCopy link to clipboard
a!customFieldDateDiff( startDate, endDate, interval )
Used to create a real-time custom record field, this function returns the difference between two dates as a Number (Integer). The difference can be returned in days, hours, minutes, or seconds. Returns null when the startDate
or endDate
is null or empty.
ParametersCopy link to clipboard
Keyword | Type | Description |
---|---|---|
|
Any Type |
The record field or expression that evaluates to a Date or Date and Time value to use in the date subtraction. |
|
Any Type |
The record field or expression that evaluates to a Date or Date and Time value to use in the date subtraction. |
|
Text |
Determines whether the difference is calculated in days, hours, minutes, or seconds. Valid values are "DAY" (default), "HOUR", "MINUTE", "SECOND". |
Usage considerationsCopy link to clipboard
Where to use this functionCopy link to clipboard
The a!customFieldDateDiff()
function can only be used to create a custom record field that evaluates in real time. This means you can reference related record fields, constants, and other supported functions in your calculations.
To create a custom record field that evaluates in real-time:
- In your record type, go to Data Model.
- Click NEW CUSTOM RECORD FIELD.
- From SELECT A TEMPLATE, choose Write Your Own Expression.
- Choose Real-time evaluation.
- Click NEXT.
-
Enter an expression using any Custom Field function.
Note: Custom record fields that evaluate in real-time must use at least one Custom Field function.
- Click NEXT.
- Enter a Name for your custom record field.
- Click CREATE.
- Click SAVE CHANGES. The new custom record field appears in your list of fields.
Using the startDate and endDate parametersCopy link to clipboard
By default, the startDate parameter is subtracted from the endDate parameter. This means that if the startDate is 12/1/2022
and the endDate is 12/10/2022
, the resulting value would be 9
days.
You can use the following values in the startDate and endDate parameters:
- Record field or related record fields of type Date or Date and Time. Use the
recordType!
domain to reference your fields. For example,recordType!Case.fields.submittedDate
. -
Relative date and time functions, like
today()
ornow()
.Note: You cannot use a relative date and time function in both parameters.
- Constants.
If either parameter is null or empty, a null value is returned.
ExampleCopy link to clipboard
Let’s say you want to display the number of days it took to deliver each order on a read-only grid. You could use this function to create a custom record field that subtracts the submittedDate
and the deliveryDate
and returns the difference in days. If the order hasn’t been delivered yet (so the delivery date is null), then subtract the submittedDate from today’s date.
The expression would look something like this:
1
2
3
4
5
6
7
8
a!customFieldDateDiff(
startDate: recordType!Order.fields.submittedDate,
endDate: a!customFieldDefaultValue(
value: recordType!Order.fields.deliveryDate,
default: today()
),
interval: "DAY"
)
Copy
Tip: For more examples using the a!customFieldDateDiff()
function, check out the AR_DateDiffDashboard in the Appian Retail application available for free in Appian Community Edition.
Supported functionsCopy link to clipboard
You can use any of the following supported functions in the interval parameter of a!customFieldDateDiff()
. This allows you to use functions like if()
or not()
to determine which interval value to return.
Note: When you use a supported function in a Custom Field function, you can only pass static values or constants containing static values into the supported function; you cannot pass record field references.
Feature compatibilityCopy link to clipboard
The table below lists this function's compatibility with various features in Appian.
Feature | Compatibility | Note |
---|---|---|
Portals | Partially compatible | Can be used with Appian Portals if it is connected using an integration and web API. |
Offline Mobile | Incompatible | |
Sync-Time Custom Record Fields | Incompatible | |
Real-Time Custom Record Fields | Compatible | Can only be used to create a custom record field that evaluates in real time. It cannot be used anywhere else in your application. |
Process Reports | Incompatible | Cannot be used to configure a process report. |
Process Events | Incompatible | Cannot be used to configure a process event node, such as a start event or timer event. |