
HP COBOL Reference Manual
7.43 TAN
Description
The TAN function returns a numeric value that approximates the tangent
of an angle or arc, expressed in radians, that is specified by the
argument.
arg
is a numeric or integer argument.
Rules
 The type of this function is numeric.
 The returned value is the approximate tangent of the angle
specified.
Example
COMPUTE TANRSLT = FUNCTION TAN (X).

X and TANRSULT are numeric data items. If the value of X is 3, the
approximate tangent of an angle of 3 radians is moved to TANRSLT.
7.44 TESTDATEYYYYMMDD
Description
The TESTDATEYYYYMMDD function tests whether a standard date in the
form YYYYMMDD is a valid date in the Gregorian calendar.
General Format
FUNCTION TESTDATEYYYYMMDD ( arg )

arg
is an integer.
Rules
 The type of this function is integer.
 If the year is not within the range 1601 through 9999, the
function returns a 1.
Otherwise, if the month is not within the
range 1 through 12, the function returns a 2. Otherwise, if the
number of days is invalid for the given month, the function returns a
3. Otherwise, the function returns a 0 to indicate the date is a
valid date in the form YYYYMMDD.
Example
IF FUNCTION TESTDATEYYYYMMDD (123456789) = 1
DISPLAY "correct  invalid year (12345)".
IF FUNCTION TESTDATEYYYYMMDD (19952020) = 2
DISPLAY "correct  invalid mm (20)".
IF FUNCTION TESTDATEYYYYMMDD (19950229) = 3
DISPLAY "correct  invalid dd (29)".
IF FUNCTION TESTDATEYYYYMMDD (20040229) = 0
DISPLAY "correct  valid YYYYMMDD".

7.45 TESTDAYYYYYDDD
Description
The TESTDAYYYYYDDD function tests whether a Julian date in the form
YYYYDDD is a valid date in the Gregorian calendar.
General Format
FUNCTION TESTDAYYYYYDDD ( arg )

arg
is an integer.
Rules
 The type of this function is integer.
 If the year is not within the range 1601 through 9999, the
function returns a 1.
Otherwise, if the number of days is invalid
for the given year, the function returns a 2. Otherwise, the
function returns a 0 to indicate the date is a valid date in the form
YYYYDDD.
Example
IF FUNCTION TESTDAYYYYYDDD (12345678) = 1
DISPLAY "correct  invalid year (12345)".
IF FUNCTION TESTDAYYYYYDDD (1995366) = 2
DISPLAY "correct  invalid ddd (366)".
IF FUNCTION TESTDAYYYYYDDD (2004366) = 0
DISPLAY "correct  valid YYYYDDD".

7.46 UPPERCASE
Description
The UPPERCASE function returns a character string that is the same
length as the argument with each lowercase letter in the argument
replaced by the corresponding uppercase letter.
string
is an alphabetic or alphanumeric argument at least one character in
length.
Rules
 The type of this function is alphanumeric.
 The returned value is the same character string as the argument,
except that each lowercase letter in the argument is replaced by the
corresponding uppercase letter.
Examples

MOVE FUNCTION UPPERCASE (STR) TO UCSTR.

If STR (an alphanumeric data item six characters in length) contains
the value "Autumn" the value returned and stored in UCSTR (also an
alphanumeric data item six characters in length) is "AUTUMN"; if STR
contains "FALL98" the value returned is unchanged ("FALL98").

ACCEPT NAMEFIELD.
WRITE RECORDOUT
FROM FUNCTION UPPERCASE(NAMEFIELD).

The value in NAMEFIELD is made alluppercase, unless it was already
alluppercase, in which case it is unchanged. Any nonalphabetic
characters remain unchanged.
7.47 VARIANCE
Description
The VARIANCE function returns a numeric value that approximates the
variance of its arguments.
arg
is an integer or numeric argument.
Rules
 The type of this function is numeric.
 The returned value is the approximation of the variance of the
argument series, and is defined as the square of the standard deviation
of the argument series. (For a definition of standard deviation, see
the description of the
Section 7.41 function.)
 If the argument series consists of only one value, the returned
value is 0.
Examples

COMPUTE RSULT = FUNCTION VARIANCE (A).

The value returned and stored in RSULT is 0, because there is only one
argument.

COMPUTE RSULT = FUNCTION VARIANCE (A, B, C).

If A has the value 1, B has 2, and C has 12, the value returned and
stored in RSULT is approximately 24.667. This represents the variance,
which is the square of the standard deviation of these arguments; the
calculation is described in the description of the Section 7.41
function. In the above examples, A, B, C, and RSULT are numeric data
items.
7.48 WHENCOMPILED
Description
The WHENCOMPILED function returns the date and time the program was
compiled.
Rules
 The type of this function is alphanumeric.
 The returned value is the date and time of compilation of the
source program that contains this function. If the program is a
contained program, the returned value is the compilation date and time
associated with the separately compiled program in which it is
contained.
 The returned value denotes the same time as the compilation date
and time provided in the listing of the source program and in the
generated object code for the source program. The representation
differs, and the precision can differ, as shown in the second example.
 The contents of the character positions returned, numbered from
left to right, are as follows:
Character Positions 
Contents 
14

Four numeric digits of the year in the Gregorian calendar.

56

Two numeric digits of the month of the year, in the range 01 through 12.

78

Two numeric digits of the day of the month, in the range 01 through 31.

910

Two numeric digits of the hours past midnight, in the range 00 through
23.

1112

Two numeric digits of the minutes past the hour, in the range 00
through 59.

1314

Two numeric digits of the seconds past the minute, in the range 00
through 59.

1516

Two numeric digits of the hundredths of a second past the second, in
the range 00 through 99.

1721

The value 00000. (Reserved for future use.)

Examples
MOVE FUNCTION WHENCOMPILED TO VERSIONSTAMP.

The value returned and stored in VERSIONSTAMP (an alphanumeric data
item) is the date and time of the program's compilation.
This is a sample value returned by the WHENCOMPILED function. Reading
from left to right, it shows
 The year, 1997
 The month, January
 The day of the month, the 10th
 The time of day, 16:52 (4:52 P.M.)
 The seconds, 31, and the hundredths
of seconds, 32, after 16:52:31
This compilation date and time as shown on the compiler listing (which
does not show hundredths of seconds) is as follows:
