Types of Expressions
 In this section: Expressions and Field Formats

An expression can be one of the following:

• Numeric. Use numeric expressions to perform calculations that use numeric constants (integer or decimal) and fields. For example, you can write an expression to compute the bonus for each employee by multiplying the current salary by the desired percentage as follows:
`COMPUTE BONUS/D12.2 = CURR_SAL * 0.05 ;`

A numeric expression returns a numeric value. For details, see

• Date. Use date expressions to perform numeric calculations on dates. For example, you can write an expression to determine when a customer can expect to receive an order by adding the number of days in transit to the date on which you shipped the order as follows:
`COMPUTE DELIVERY/MDY = SHIPDATE + 5 ;`

There are two types of date expressions:

• Date expressions, which return a date, a component of a date, or an integer that represents the number of days, months, quarters, or years between two dates. For details, see
• Date-time expressions, which you can create using a variety of specialized date-time functions, each of which returns a different kind of value. For details on these functions, see the Using Functions manual.
• Character. Use character expressions to manipulate alphanumeric constants or fields. For example, you can write an expression to extract the first initial from an alphanumeric field as follows:
`COMPUTE FIRST_INIT/A1 = EDIT (FIRST_NAME, '9\$\$\$\$\$\$\$\$\$') ;`

A character expression returns an alphanumeric value. For details, see

Note: Text fields can be assigned to alphanumeric fields and receive assignment from alphanumeric fields. Text fields can also participate in expressions using the operators CONTAINS and OMITS.

• Logical. Use logical expressions to evaluate the relationship between two values. A logical expression returns TRUE or FALSE. For details, see
• Conditional. Use conditional expressions to assign values based on the result of logical expressions. A conditional expression (IF ... THEN ... ELSE) returns a numeric or alphanumeric value. For details, see
 Top of page
Expressions and Field Formats

When you use an expression to assign a value to a field, make sure that you give the field a format that is consistent with the value returned by the expression. For example, if you use a character expression to concatenate a first name and last name and assign it to the field FULL_NAME, make sure you define the field as character.

 Top of page
Example: Assigning a Field Format of Sufficient Length

The following example contains a character expression that concatenates a first name and last name to derive the full name. It assigns the field FULL_NAME an alphanumeric format of sufficient length to accommodate the concatenated name:

```DEFINE FILE EMPLOYEE
FULL_NAME/A25 = FIRST_NAME | LAST_NAME;
END
TABLE FILE EMPLOYEE
PRINT FULL_NAME
WHERE LAST_NAME IS 'BLACKWOOD'
END```

The output is:

```FULL_NAME
---------
ROSEMARIE BLACKWOOD```
 WebFOCUS