Function Definitions

Table 1 provides an overview of the argument type, function type and value returned for each of the intrinsic functions. Argument types and function types are abbreviated as follows:
  • A = alphabetic
IBM Extension
IBM Extension
  • B = boolean
  • D = DBCS
  • DA = date-time
End of IBM Extension
End of IBM Extension
  • I = integer
  • IX = Index
IBM Extension
IBM Extension
  • K = keyword
  • M = mnemonic-name
End of IBM Extension
End of IBM Extension
  • N = numeric
  • NL = national
IBM Extension
IBM Extension
  • P = pointer
  • S = special-register
  • T = type-name
End of IBM Extension
End of IBM Extension
  • X = alphanumeric
  • U = national (for Universal Character Set and Unicode)
Note: The number associated with these abbreviations, identifies which function argument is being referred to.
Table 1. Table of Functions
FUNCTION-NAME ARGUMENT TYPES FUNCTION TYPES VALUE RETURNED
ACOS N1 N Arccosine of N1
ADD-DURATION1 DA1,K2, I3 DA A date-time item with the duration added.
ANNUITY N1, I2 N Approximates an annuity paid at an interest rate of N1 for I2 periods.
ASIN N1 N Arcsine of N1
ATAN N1 N Arctangent of N1
CHAR I1 X Character in position I1 of program collating sequence
CONVERT-DATE-TIME1 DA1 or X1 or I1, K2, X3 or K3 or S3, M4 or S4 DA Converted date-time item
COS N1 N Cosine of N1
CURRENT-DATE None X Current date and time and difference from Greenwich Mean Time
DATE-OF-INTEGER I1 I Standard date equivalent (YYYYMMDD) of integer date
DATE-TO-YYYYMMDD1 I1 or I1, I2 I Converts year in standard date from 2 digits to 4 digits
DAY-OF-INTEGER I1 I Julian date equivalent (YYYYDDD) of integer date
DAY-TO-YYYYDDD1 I1 or I1, I2 I Converts year in Julian date from 2 digits to 4 digits
DISPLAY-OF

NL1

X Each character in NL1 converted to a corresponding character representation using a code page identified by I2, if specified, or a default code page selected at compile time if I2 is unspecified
NL1, I2
NL1, X2 or D2
EXTRACT-DATE-TIME1 DA1, X2 or K2 I or X Part of an extracted date, time, or timestamp item
FACTORIAL I1 I Factorial of I1
FIND-DURATION1 DA1, DA2, 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 argument
LENGTH A1, N1, X1, D1, B1, T1, DA1, P1, IX1, NL I Length of argument
LOCALE-DATE1 X1 or D1, M2 X Date string formatted according to locale specified
LOCALE-TIME1 X1 or D1, M2 X Time string formatted according to locale specified
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 are set to lowercase
D1 D
NL NL
MAX A1... X Value of maximum argument; note that the type of function depends on the arguments
I1... I
N1... N
X1... X
U1... U
MEAN N1... N Arithmetic mean of arguments
MEDIAN N1... N Median of arguments
MIDRANGE N1... N Mean of maximum and minimum arguments
MIN A1...or X Value of minimum argument; note that the type of function depends on the arguments
I1...or I
N1...or N
X1...or X
U1... U
MOD I1, I2 I I1 modulo I2
NATIONAL-OF A1 or X1 or D1 NL The characters in argument-1 converted to national characters, using the code page identified by I2, if specified, or a default code page selected at compile time if I2 is unspecified
A1 or X1 or D1, I2
A1 or X1 or D1, NL2
NUMVAL X1 N Numeric value of simple numeric string
NUMVAL-C X1 or X1,X2 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..., I Ordinal position of maximum argument
X1..., or U1...
ORD-MIN A1..., N1..., I Ordinal position of minimum argument
X1..., or U1...
Start of changePARMSEnd of change Start of changeNoneEnd of change Start of changeXEnd of change Start of changeThe number of parameters that were passed to the program or procedureEnd of change
PRESENT-VALUE N1, N2... N Present value of a series of future period-end amounts, N2, at a discount rate of N1
RANDOM I1 or 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
REM N1, N2 (N2 is nonzero) N Remainder of N1 divided by N2
REVERSE A1 or X1 X Reverse order of the characters of the argument
D1 D
NL NL
SIN N1 N Sine of N1
SQRT N1 N Square root of N1
STANDARD DEVIATION N1... N Standard deviation of arguments
SUM I1... I Sum of arguments; note that the type of function depends on the arguments
N1... N
SUBTRACT-DURATION1 DA1, K2, I3 DA A date-time item with the duration subtracted
TAN N1 N Tangent of N1
TEST-DATE-TIME1 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
TRIM1 A1 or X1 X String with left and right blanks or specified characters trimmed
A1, A2 or X1, X2
D1 or D1, D2 D
NL1 or NL1, NL2 NL
TRIML1 A1 or X1 X String with left blanks or specified characters trimmed
A1, A2 or X1, X2
D1 or D1, D2 D
NL1 or NL1, NL2 NL
TRIMR1 A1 or X1 X String with right blanks or specified characters trimmed
A1, A2 or X1, X2
D1 or D1, D2 D
NL1 or NL1, NL2 NL
UPPER-CASE A1 or X1 X All letters in the argument are set to uppercase
D1 D
NL NL
UTF8STRING1 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-YYYY1 I1 or I1, I2 I Converts year from 2 digits to 4 digits
Note: 1 IBM® Extension

The following sections contain the function definitions for each of the Intrinsic Functions summarized in Table 1.