Function definitions

This section provides an overview of the argument type, function type, and value returned for each of the intrinsic functions.

For more information about the intrinsic functions, see Table 1.

Argument types and function types are abbreviated as follows:

Abbreviation Meaning
A Alphabetic
B Boolean
D DBCS
DA Date-time
I Integer
IX Index
K Keyword
M Mnemonic-name
N Numeric
O Other, as specified in the function definition (pointer, function-pointer, or procedure-pointer)
P Pointer
S Special-register
T Type-name
U National
X Alphanumeric

The behavior of functions marked"DP" depends on whether the DATEPROC or NODATEPROC compiler option is in effect.

If the DATEPROC compiler option is in effect, the following intrinsic functions return date fields:

Function Returned value has implicit DATE FORMAT
DATE-OF-INTEGER YYYYXXXX
DATE-TO-YYYYMMDD YYYYXXXX
DAY-OF-INTEGER YYYYXXX
DAY-TO-YYYYDDD YYYYXXX
YEAR-TO-YYYY YYYY
DATEVAL Depends on the format specified by DATEVAL
YEARWINDOW YYYY

If the NODATEPROC compiler option is in effect:

  • The following intrinsic functions return the same values as when DATEPROC is in effect, but their returned values are nondates:
    • DAY-OF-INTEGER
    • DATE-TO-YYYYMMDD
    • DAY-TO-YYYYDDD
    • YEAR-TO-YYYY
  • The DATEVAL and UNDATE intrinsic functions have no effect, and simply return their (first) arguments unchanged.
  • The YEARWINDOW intrinsic function returns 0 unconditionally.

Each intrinsic function is described in detail in the topics that follow the table below.

Table 1. Table of functions
Function name Arguments Function type Value returned
ACOS N1 N Arccosine of N1
ADD-DURATION DA1, K2, I3 DA A date-time item with the duration added
ANNUITY N1, I2 N Ratio of annuity paid for I2 periods at interest of N1 to initial investment of one
ASIN N1 N Arcsine of N1
ATAN N1 N Arctangent of N1
CHAR I1 X Character in position I1 of program collating sequence
COS N1 N Cosine of N1
CURRENT-DATE None X Current date and time and difference from Greenwich mean time
CONVERT-DATE-TIME DA1 or X1 or I1, K2, X3 or K3 or S3, M4 or S4 DA Converted date-time item
DATE-OF-INTEGERDP I1 I Standard date equivalent (YYYYMMDD) of integer date
DATE-TO-YYYYMMDDDP I1, I2 I Standard date equivalent (YYYYMMDD) of I1 (standard date with a windowed year, YYMMDD), according to the 100-year interval whose ending year is specified by the sum of I2 and the year at execution time
DATEVALDP I1 I Date field equivalent of I1
X1 X Date field equivalent of X1
DAY-OF-INTEGERDP I1 I Julian date equivalent (YYYYDDD) of integer date
DAY-TO-YYYYDDDDP I1, I2 I Julian date equivalent (YYYYDDD) of I1 (Julian date with a windowed year, YYDDD), according to the 100-year interval whose ending year is specified by the sum of I2 and the year at execution time
DISPLAY-OF
U1 or
U1, I2, or
U1, X2, or D2
X Each character in U1 converted to a corresponding character representation using a code page identified by I2, if specified, or the code page specified by the runtime locale if I2 is unspecified
EXTRACT-DATE-TIME DA1, X2, or K2 I or X Part of an extracted date, time, or timestamp item
FACTORIAL I1 I Factorial of I1
FIND-DURATION DA1, DA2, or K3 I The integer duration between 2 date-time items
INTEGER N1 I The greatest integer not greater than N1
INTEGER-OF-DATE I1 I Integer date equivalent of standard date (YYYYMMDD)
INTEGER-OF-DAY I1 I Integer date equivalent of Julian date (YYYYDDD)
INTEGER-PART N1 I Integer part of N1
LENGTH A1, B1, D1, DA1, IX1, N1, O1, P1, T1, X1, or U1 I Length of argument in national character positions or in alphanumeric character positions or bytes, depending on the argument type
LOG N1 N Natural logarithm of N1
LOG10 N1 N Logarithm to base 10 of N1
LOWER-CASE A1 or X1 X All letters in the argument set to lowercase
U1 U All letters in the argument set to lowercase
MAX A1... X Value of maximum argument; note that the type of function depends on the arguments
I1... I Value of maximum argument; note that the type of function depends on the arguments
N1... N Value of maximum argument; note that the type of function depends on the arguments
X1... X Value of maximum argument; note that the type of function depends on the arguments
U1... U Value of maximum argument; note that the type of function depends on the arguments
MEAN N1... N Arithmetic mean of arguments
MEDIAN N1... N Median of arguments
MIDRANGE N1... N Mean of minimum and maximum arguments
MIN A1... X Value of minimum argument; note that the type of function depends on the arguments
I1... I Value of minimum argument; note that the type of function depends on the arguments
N1... N Value of minimum argument; note that the type of function depends on the arguments
X1... X Value of minimum argument; note that the type of function depends on the arguments
U1... U Value of minimum argument; note that the type of function depends on the arguments
MOD I1, I2 I I1 modulo I2
NATIONAL-OF A1, X1, or D1 U The characters in the argument converted to national characters, using the code page identified by I2, if specified, or a code page specified by the runtime locale if I2 is unspecified
A1, X1, or D1; I2 U The characters in the argument converted to national characters, using the code page identified by I2, if specified, or a code page specified by the runtime locale if I2 is unspecified
A1 or X1 or D1, U2 U The characters in the argument converted to national characters, using the code page identified by I2, if specified, or a code page specified by the runtime locale if I2 is unspecified
NUMVAL X1 or U1 N Numeric value of simple numeric string
NUMVAL-C
X1 or U1;
X1, X2;
U1, U2
N Numeric value of numeric string with optional commas and currency sign
ORD A1 or X1 I Ordinal position of the argument in collating sequence
ORD-MAX A1..., N1..., X1..., or U1... I Ordinal position of maximum argument
ORD-MIN A1..., N1..., X1..., or U1... I Ordinal position of minimum argument
PRESENT-VALUE N1, N2... N Present value of a series of future period-end amounts, N2, at a discount rate of N1
RANDOM I1, none N Random number
RANGE I1... I Value of maximum argument minus value of minimum argument; note that the type of function depends on the arguments.
N1... N Value of maximum argument minus value of minimum argument; note that the type of function depends on the arguments.
REM N1, N2 N Remainder of N1/N2
REVERSE A1 or X1 X Reverse order of the characters of the argument
U1 U Reverse order of the characters of the argument
SIN N1 N Sine of N1
SQRT N1 N Square root of N1
STANDARD-DEVIATION N1... N Standard deviation of arguments
SUBTRACT-DURATION DA1, K2, I3 DA A date-time item with the duration subtracted
SUM I1... I Sum of arguments; note that the type of function depends on the arguments.
N1... N Sum of arguments; note that the type of function depends on the arguments.
TAN N1 N Tangent of N1
TEST-DATE-TIME DA1 or X1 or I1, K2, X3 or K3 or S3, M4 or S4 B True (B"1") if valid date-time item, otherwise false
TRIM A1 or X1 X String with left and right blanks or specified characters trimmed
A1, A2 or X1, X2 String with left and right blanks or specified characters trimmed
D2 or D1, D2 D String with left and right blanks or specified characters trimmed
NL1 or NL1, NL2 NL String with left and right blanks or specified characters trimmed
TRIML A1 or X1 X String with left blanks or specified characters trimmed
A1, A2 or X1, X2 String with left blanks or specified characters trimmed
D1 or D1, D2 D String with left blanks or specified characters trimmed
NL1 or NL1, NL2 NL String with left blanks or specified characters trimmed
TRIMR A1 or X1 X String with right blanks or specified characters trimmed
A1, A2 or X1, X2 String with right blanks or specified characters trimmed
D1 or D1, D2 D String with right blanks or specified characters trimmed
NL1 or NL1, NL2 NL String with right blanks or specified characters trimmed
UNDATEDP I1 I Nondate equivalent of date field I1 or X1
X1 X Nondate equivalent of date field I1 or X1
UPPER-CASE A1 or X1 X All letters in the argument set to uppercase
U1 U All letters in the argument set to uppercase
UTF8STRING A1, X1, D1, or NL1 A Variable length UTF-8 string
VARIANCE N1... N Variance of arguments
WHEN-COMPILED None X Date and time when program was compiled
YEAR-TO-YYYYDP I1, I2 I Expanded year equivalent (YYYY) of I1 (windowed year, YY), according to the 100-year interval whose ending year is specified by the sum of I2 and the year at execution time
YEARWINDOWDP None I If the DATEPROC compiler option is in effect, returns the starting year (in the format YYYY) of the century window specified by the YEARWINDOW compiler option; if NODATEPROC is in effect, returns 0