min, max Functions

Prev Next

Function Names

min, max ignore zero, min ignore blanks, max, max ignore zero, max ignore blanks

Description

min / max…: Compares all values inside the function parameter or parameter set together, using type checking and comparison rules as given for the binary operators < (for min) and > (for max).
The suffix ... ignore zero excludes all zero values and blank (=zero) dates.
The suffix ... ignore blanks excludes all strings with blank contents. Note: Blank dates can be ignored with ... ignore zero. For the functions desccribed here, strings containing white spaces only are considered blank, too.
Providing mixed types, e.g. a combination of numerals and strings, will assert exceptions. Only the ... ignore blanks suffix tolerates blank strings in the parameters where the others are other types, e.g. numerals.

Minimum Function Name Maximum Function Name Autom. Type conversion Description
min max No Picks minimum or maximum value provided
min ignore zero max ignore zero No ", but ignores 0 and blank dates
min ignore blanks max ignore blanks No ", but ignores blank strings.

Please note that equivalent conditional combination functions are also available for the function names listed above which allows you to pre-select specific parameters to include in the calculation using one or more comparisons .

Call as: function

Parameter count

Min 1

Parameters

No.TypeDescription
1, etc.
input
valid types All function parameters:

Same parameter passing principle is applied like other series functions such as add(), sub(), etc.
See Two parameter passing methods for series functions for details..

Return value

TypeDescription
valid types Result

Calculated value

Exceptions

Attempting to compare incompatible types, e.g. numerals with strings

Examples

      echo( "dates, 0 ignored  : ", min ignore zero( date(""), date("2020-03-23"), date("2020-03-20") ) );
      echo( "dates compared    : ", min ( date(""), date("2020-03-23"), date("2020-03-20") ) );
      echo( "numbers w/o blanks: ", min ignore blanks( 5, 8, "", 1 ) );
      echo( "strings          : ", max( "He", "he", "hi", "Hi" ) ); // Max = last in alphabetic order
//        echo( "causes exception  : ", max ( 1, a, 2, b ) ); // Commented out because it's wrong.

Output

dates, 0 ignored  : 2020-03-20
dates compared    :
numbers w/o blanks: 1
strings          : hi
Try it yourself: Open LIB_Function_min.b4p in B4P_Examples.zip. Decompress before use.

See also

min 123
max 123
min numeral
max numeral
min abc
max abc
min string
max string