Date Conversion Utility
Easytrieve Plus provides utilities to convert dates. Unfortunately,
it only works when the date fields are numeric. It cannot handle
dates in formats such as mm/dd/yy.
This utility encompasses the same features as the Easytrieve Plus
DATECONV utility but also includes non-numeric
date formats.
Date formats are general, like DATECONV formats,
but permit non-numeric formats. Certain format elements are key,
and are are searched for by this utility, namely:
- DD -- indicating a day
- MM - indicating a month
- CC - indicating the century part of a year
- YY - indicating the year part (non-century) of a year
Whichever of these elements is used in either an input or output
format must be present in the other (output or input) format, with
one exception. Century may be part of the output format without
being specified as part of the input format.
When finished, the routine issues a return code, indicating the
success of the routine.
The routine is useable in Easytrieve Plus or Cobol. Easytrieve Plus
uses an Include. Cobol programs can issue a direct call to the
routine.
Easytrieve Plus Include
The Include member is IS9045B. It does the actual
interface to the conversion program (IS9045A). This
include uses the following 5 arguments:
- Input Date: This is the date to be reformatted (up to 10 bytes).
- Input Date Format: Specifies the format of the date to be
reformatted, using DD to indicate which is the
day, MM to indicate the month,
CC to indicate the century (if any) and
YY to indicate the year (minus the century).
For example, a date of 01/25/1993 would have a format of
MM/DD/CCYY and a date of 199507 would have a
format of CCYYMM.
- Output date: This is the output date after formatting (up to 10
bytes).
- Output Date Format: Specifies the format in which the date is to
be returned. Uses the same scheme as input date. For example,
an input date of 10/15/98 in MM/DD/YY format
would be output as 10-15-98 with an output format of
MM-DD-YY and would be 10*15*1998 with an output
format of MM*DD*CCYY.
- Return Code: Indicates the status of the date conversion effort.
The following statuses may be returned:
- 0 - the date conversion was successful.
- 1 - Input and Output date formats do
not agree. See limitations for further
information.
The IS9045B Include is invoked as follows:
%IS9045B vvv 'www' xxx 'yyy' zzz
where vvv is the variable containing the input date.
www is the input date format. xxx
is the variable containing the output date. yyy is
the output date format and zzz is the variable
representing the return variable.
Mechanics
This routine scans the input date format. It seeks the positions of
MMDD, CC and
YY. It finds the positions of these in the output
format as well. It then places the output format into the output date
field and proceeds to move data from input date to output date
based on the positions (if any) that are found.
JCL Requirements
No special JCL is required to use this routine.
Example
A sample program (call it TEST01) might look as follows:
MACRO
FILE FILE01
WDATEIN W 008 A VALUE '10151998'
WDATEOUT W 010 A
WRTNCD W 001 A
JOB INPUT NULL
%IS9045B WDATEIN 'MMDDCCYY' WDATEOUT 'MM%DD%CCYY' WRTNCD
DISPLAY 'DATE IN= ' WDATEIN
DISPLAY 'DATE OUT=' WDATEOUT
DISPLAY 'RETURN CODE=' WRTNCD
STOP
This is a very simplistic example of use of the IS9045A routine. It
will return 10%15%1998 when finished with a return
code of 0.
Limitations
- If DD, MM or YY is specified on the input format, it must be
specified on the output format (and vice versa).
- If CC is specified on the output format, but not on the input
format, the century is determined to be 19
if the value for YY is under 25. Otherwise, the value for
CC will be set to 20.
- No validation is done to determine if the input date is a
valid date.
- DD, MM, CC or YY is specified twice (or more) in a format,
the last occurrence is used.
- Date lengths are limited to 10 bytes each, as are the date
format fields. The return code is specified as 1 byte. if the
length of calling fields are larger, they will be truncated to
these lengths when processed.
Technical
The IS9045B Easytrieve Plus routine calls a Cobol routine called
IS9045A.
All variables used by this routine have a suffix of ##
to prevent duplicate variable names. Should a program using this
routine use the same convention, see the IS9045B
Include module for variable definitions.
OIT--Applications Support
Last Modified: Tuesday, 28-Nov-2000 10:34:41 CST
©2000 All Rights Reserved