Free cookie consent management tool by TermsFeed

a!customFieldDateDiff() Function

Function

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.

Parameters

Keyword Type Description

startDate

Any Type

The record field or expression that evaluates to a Date or Date and Time value to use in the date subtraction.

endDate

Any Type

The record field or expression that evaluates to a Date or Date and Time value to use in the date subtraction.

interval

Text

Determines whether the difference is calculated in days, hours, minutes, or seconds. Valid values are "DAY" (default), "HOUR", "MINUTE", "SECOND".

Usage considerations

Where to use this function

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:

  1. In your record type, go to Data Model.
  2. Click NEW CUSTOM RECORD FIELD.
  3. From SELECT A TEMPLATE, choose Write Your Own Expression.
  4. Choose Real-time evaluation.
  5. Click NEXT.
  6. 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.

  7. Click NEXT.
  8. Enter a Name for your custom record field.
  9. Click CREATE.
  10. Click SAVE CHANGES. The new custom record field appears in your list of fields.

Using the startDate and endDate parameters

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() or now().

    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.

Example

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 functions

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 compatibility

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.

Feedback