MAXIMUM( ) function

Returns the maximum value in a set of numeric values, or the most recent value in a set of datetime values.

Syntax

MAXIMUM(value_1, value_2 <,...n>)

Parameters

Name Type Description
value_1, value_2 <, ...n>

numeric

datetime

The values to compare, separated by commas.

All values must be of the same data type.

Additionally, datetime values must be of the same subtype. You cannot mix date, datetime, or time values in a single execution of the function.

Output

Numeric or Datetime.

Examples

Basic examples

Literal numeric input

Returns 7:

MAXIMUM(4, 7)

Returns 8:

MAXIMUM(4, 7, 3, 8)

Returns 8.00:

MAXIMUM(4, 7.25, 3, 8)

Literal datetime input

Returns `20161231`:

MAXIMUM(`20161231`, `20161229`, `20161230`)

Returns `20161231 23:59:59`:

MAXIMUM(`20161231 235959`, `20161229 235959`)

Returns `23:59:59`:

MAXIMUM(`.235957`, `.235959`, `.235958`)

Field input

Returns the most recent date among the three fields for each record:

MAXIMUM(PO_Date, Invoice_Date, Payment_Date)

Advanced examples

Creating a computed field with a minimum default value

If you have a table of overdue accounts, create an Interest_Due computed field with a minimum default value of $1.00:

DEFINE FIELD Interest_Due COMPUTED MAXIMUM(BALANCE * ANNUAL_RATE, 1)

If the balance multiplied by the interest rate is less than one dollar, MAXIMUM( ) returns 1. Otherwise, MAXIMUM( ) returns the calculated interest amount.

Discovering dates past the end of a quarter

To discover if any dates across multiple fields are past the end of a quarter, create a computed field with an expression like the one below:

DEFINE FIELD Past_Qtr COMPUTED MAXIMUM(PO_Date, Invoice_Date, Payment_Date, `20160331`)
  • Records with all dates on or before 31 Mar 2016 return `20160331`.
  • Records with one or more dates after 31 Mar 2016 return the most recent date among the three fields.

Remarks

How decimal places work in sets of numeric values

If the numeric values being compared do not have the same number of decimal places, the result is adjusted to the largest number of decimal places.

Returns 20.400:

MAXIMUM(3.682, 10.88, 20.4)

You can use the DECIMALS( ) function to adjust the number of decimals for value parameters.

Returns 20.40:

MAXIMUM(DECIMALS(3.682, 2), 10.88, 20.4)
ACL Scripting Guide 14.1