TAA Tools
CVTDAT2         CONVERT DATE 2                         TAADATZ

The Convert  Date 2 command  is similar to  the system CVTDAT  command,
but supports  a wider range  of dates.   The system command  is limited
to  dates of  1940 to 2039  or 1928 to  2071 depending  on the formats.
The CVTDAT2 command  has a range of  years from 1600  to 4000.  All  of
the date formats supported by CVTDAT are supported by CVTDAT2.

A typical command would be:

             DCL           &TODATE *CHAR LEN(10)
              .
             CVTDAT2       DATE(nnnnnn) TOVAR(&TODATE)
                             FROMFMT(*MDY) TOFMT(*YYMD) TOSEP(*NONE)

The  date  in MMDDYY  format  would  be  converted to  YYYYMMDD  format
without separators.

All the date formats of CVTDAT are supported.

When  converting from  a 6  digit date  (such as *MDY  format) to  an 8
digit date (such as as *MDYY format) a century is assumed as follows:

       Years 40 - 99 = 20th century
       Years 00 - 39 = 21st century

Comparison of CVTDAT and CVTDAT2
--------------------------------

The parameter names on CVTDAT are  the same as used on CVTDAT2 as  well
as the special values.

CVTDAT lets  you describe  the exact  size of  the return variable  for
the  parameter  TOVAR.   CVTDAT2  requires a  10  byte  character field
regardless of the TOFMT value.   CVTDAT sends an escape message if  the
return variable is not  large enough to hold the converted  value.  For
example, if  you have a 6 byte  return variable, it is an  error if you
use TOFMT(*YYMD).

The  system  command  CVTDAT  is  limited  in  the  dates  that  it can
convert.  The dates which can  be converted are from 1940 to 2039  if a
two digit year  format is used.   If a four digit year  format is used,
the  date to  be converted  must  be between  Aug 24,  1928 and  May 9,
2071.  For  a complete discussion,  see the 2nd  level text of  message
ID CPF0557.

The  CVTDAT  century  portion  of the  system  *CYMD  format  does  not
include  years  beyond 2071.    CVTDAT2 supports  0-9  which  means the
years 1900 to 2800.  See the later discussion.

CVTDAT2 has a range of 1600 to 4000.

CVTDAT  issues  several   escape  messages  depending   on  the   error
condition.   CVTDAT2 uses TAA9893  for all errors  and varies the  text
depending on the error condition.

*CYMD Format
------------

The *CYMD format  uses the one digit century value  0 for years 1900 to
1999, 1 = years 2000 to 2099, ...  9 = years 2800 to 2899.

It  is considered invalid to convert a  date that has a century outside
of 19-28 to a *CYMD format.

CVTDAT2  escape messages you can monitor for
--------------------------------------------

      TAA9893    Invalid date (the text contains the specific error)

Escape messages from based on functions will be re-sent.

The text for the  message will contain a  more explicit reason such  as
invalid data (non-digits) or an invalid day or month.

Gregorian Calendar
------------------

The Gregorian calendar is used for the dates.

The 1600  year minimum date  is set to  coincide with the  beginning of
the  Georgian calendar  (named for  Pope Gregory  XIII) which  began in
1582.  Countries  were slow  to adopt  the new standard.   England  and
the American colonies did not adopt the new calendar until 1752.

Command parameters                                    *CMD
------------------

   DATE          The  date to  be converted.    It must  adhere to  the
                 format of the FROMFMT parameter.

   TOVAR         The  converted  date  that is  returned.    The return
                 parameter must  be declared  as *CHAR  LEN(10) and  is
                 large enough to contain any TOFMT date formatting.

   FROMFMT       The format  of the DATE  value to  be converted.   The
                 default  is  *JOB.    The  other values  that  may  be
                 specified  are  the  same  as  on  the  system  CVTDAT
                 command including  *SYSVAL,  *MDY, *DMY,  *YMD,  *JUL,
                 *LONGJUL,  *MDYY,  *DMYY,  *YYMD, *CYMD,  *ISO,  *USA,
                 *EUR, and *JIS.

   TOFMT         The  format of  the TOVAR value  to be  returned.  The
                 default is  *JOB.    The  other  values  that  may  be
                 specified  are  the  same  as  on  the  system  CVTDAT
                 command  including  *SYSVAL, *MDY,  *DMY,  *YMD, *JUL,
                 *LONGJUL, *MDYY,  *DMYY,  *YYMD,  *CYMD,  *ISO,  *USA,
                 *EUR, and *JIS.

   TOSEP         Whether separator  characters  should be  used in  the
                 TOVAR return  date.  The  default is *JOB  meaning the
                 value  seen on DSPJOB.   The other  values that may be
                 specified  are  the  same  as  on  the  system  CVTDAT
                 command  including  *SYSVAL,  *NONE,  *BLANK,  or  the
                 values '/' ',' '.' and '-'.

Restrictions
------------

Because  the command returns  a variable, it  may only be used  in a CL
program.

Prerequisites
-------------

The following TAA Tools must be on your system:

     SNDESCMSG       Send escape message

Implementation
--------------

None, the tool is ready to use.

Objects used by the tool
------------------------

   Object        Type    Attribute      Src member    Src file
   ------        ----    ---------      ----------    ----------

   CVTDAT2       *CMD                   TAADATZ       QATTCMD
   TAADATZC      *PGM       CLP         TAADATZC      QATTCL
					

Added to TAA Productivity tools July 1, 1999


Home Page Up to Top