The following examples illustrate complex formula user-defined fields using conditional expressions.
The example Date UDF used is [Creation Date].
Example 1
| Code |
|
This example compares a date field with a constant date, using the Date function to format the date properly. The formula returns an alphanumeric value. If the date is later than the supplied date, the field has a value of “New”. If the date is earlier than the supplied date; the field has a value of “Old”.
Example 2
| Code |
|
This example inspects the Country field of an Address Book entry to determine if the entry is located in North America or not. It uses the alphanumeric Search function to look for the countries “Canada”, “USA”, or “Mexico”. If none of those strings are found in the entry’s Country field, the formula evaluates to “Other”, but if one of those strings is found it outputs “North America”.
Example 3
| Code |
|
This example uses the Dayofweek function to get the day of the week expressed as an integer value for a date field. It compares the value with integer values and outputs a string representing the day of the week in. If it does not have a value; it outputs an empty string.
Example 4
| Code |
|
This example formats an alphanumeric UDF such that it displays the following format of a date UDF:
eg. 15 Jan