360 lines
14 KiB
HTML
360 lines
14 KiB
HTML
|
|
<!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head><META http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<title>Convert Date (CVTDAT)</title>
|
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<a name="CVTDAT.Top_Of_Page"></a>
|
|
<h2>Convert Date (CVTDAT)</h2>
|
|
<table width="100%">
|
|
<tr>
|
|
<td valign="top" align="left"><b>Where allowed to run: </b>Compiled CL program or interpreted REXX (*BPGM *IPGM *BREXX *IREXX)<br>
|
|
<b>Threadsafe: </b>No
|
|
</td>
|
|
<td valign="top" align="right">
|
|
<a href="#CVTDAT.PARAMETERS.TABLE">Parameters</a><br>
|
|
<a href="#CVTDAT.COMMAND.EXAMPLES">Examples</a><br>
|
|
<a href="#CVTDAT.ERROR.MESSAGES">Error messages</a></td>
|
|
</tr>
|
|
</table>
|
|
|
|
<div> <a name="CVTDAT"></a>
|
|
<p>The Convert Date (CVTDAT) command converts the format of a date value from one format to another, without changing its value. The command ignores any date separators used in the old format, but if separators are included in the converted result, a separator character can be specified on the command.
|
|
</p>
|
|
<p>Only valid dates can be converted. If either the from-format or the to-format use only 2 digits to specify the year (for example, *MDY, *DMY, *YMD, or *JUL), valid dates are in the range of January 1, 1940, to December 31, 2039. Otherwise, valid dates are in the range of August 24, 1928, to May 9, 2071. If the year is specified with only 2 digits, years in the range of 40 to 99 are assumed to be 1940 to 1999; years in the range 00 to 39 are assumed to be 2000 to 2039. The command works in conjunction with the QLEAPADJ system value.
|
|
</p>
|
|
<p><b>Restrictions:</b> This command is valid only within a CL procedure.
|
|
</p>
|
|
</div>
|
|
<table width="100%">
|
|
<tr><td align="right"><a href="#CVTDAT.Top_Of_Page">Top</a></td></tr>
|
|
</table>
|
|
<hr size="2" width="100%">
|
|
|
|
<div>
|
|
<h3><a name="CVTDAT.PARAMETERS.TABLE">Parameters</a></h3>
|
|
<table border="1" cellpadding="4" cellspacing="0">
|
|
<!-- col1="10" col2="15" col3="30" col4="10" -->
|
|
<tr>
|
|
<th bgcolor="aqua" valign="bottom" align="left">Keyword</th>
|
|
<th bgcolor="aqua" valign="bottom" align="left">Description</th>
|
|
<th bgcolor="aqua" valign="bottom" align="left">Choices</th>
|
|
<th bgcolor="aqua" valign="bottom" align="left">Notes</th>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top"><a href="#CVTDAT.DATE"><b>DATE</b></a></td>
|
|
<td valign="top">Date to be converted</td>
|
|
<td valign="top"><i>Character value</i></td>
|
|
<td valign="top">Required, Positional 1</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top"><a href="#CVTDAT.TOVAR"><b>TOVAR</b></a></td>
|
|
<td valign="top">CL var for converted date</td>
|
|
<td valign="top"><i>Character value</i></td>
|
|
<td valign="top">Required, Positional 2</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top"><a href="#CVTDAT.FROMFMT"><b>FROMFMT</b></a></td>
|
|
<td valign="top">From date format</td>
|
|
<td valign="top">*SYSVAL, *MDY, *DMY, *YMD, *JUL, <b><u>*JOB</u></b>, *MDYY, *DMYY, *YYMD, *CYMD, *ISO, *USA, *EUR, *JIS, *LONGJUL</td>
|
|
<td valign="top">Optional, Positional 3</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top"><a href="#CVTDAT.TOFMT"><b>TOFMT</b></a></td>
|
|
<td valign="top">To date format</td>
|
|
<td valign="top">*SYSVAL, *MDY, *DMY, *YMD, *JUL, <b><u>*JOB</u></b>, *MDYY, *DMYY, *YYMD, *CYMD, *ISO, *USA, *EUR, *JIS, *LONGJUL</td>
|
|
<td valign="top">Optional, Positional 4</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top"><a href="#CVTDAT.TOSEP"><b>TOSEP</b></a></td>
|
|
<td valign="top">To date separator</td>
|
|
<td valign="top">*SYSVAL, *NONE, <b><u>*JOB</u></b>, *BLANK, '/', '-', '.', ','</td>
|
|
<td valign="top">Optional, Positional 5</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<table width="100%">
|
|
<tr><td align="right"><a href="#CVTDAT.Top_Of_Page">Top</a></td></tr>
|
|
</table>
|
|
</div>
|
|
<div> <a name="CVTDAT.DATE"></a>
|
|
<h3>Date to be converted (DATE)</h3>
|
|
<p>Specifies the constant or CL variable containing the date to be converted. When a constant is specified that contains separator characters, it must be enclosed in apostrophes (the separator characters are ignored in the conversion). If separators are used in a constant, leading zeros in each part of the date can be omitted (3/3/88 or 03/03/88 are both valid). If a variable is specified, it must be long enough to contain the date type and its date separators, if used. The valid date separators are the slash (/), hyphen (-), period (.), and comma (,). A variable containing all blanks (X'40') is considered to have a date of length zero, and is not valid.
|
|
</p>
|
|
<p>This is a required parameter.
|
|
</p>
|
|
</div>
|
|
<table width="100%">
|
|
<tr><td align="right"><a href="#CVTDAT.Top_Of_Page">Top</a></td></tr>
|
|
</table>
|
|
<div> <a name="CVTDAT.TOVAR"></a>
|
|
<h3>CL var for converted date (TOVAR)</h3>
|
|
<p>Specifies the name of the CL variable that contains the converted date value.
|
|
</p>
|
|
<p>For every format except Julian, the month and day subfields in the converted result are each 2 bytes in length, are right-justified, and (if necessary) a leading zero is used as a padding character to fill each 2-byte field.
|
|
</p>
|
|
<p>For the Julian and long Julian formats, the day field is 3 bytes long and padded with leading zeros (if necessary). The year field is 2 bytes long for Julian and 4 bytes long for long Julian.
|
|
</p>
|
|
<p>Use the following tables to determine the required minimum length of the variable.
|
|
</p>
|
|
<p><b>Field Size and Minimum Variable Length</b>
|
|
</p>
|
|
<p>
|
|
<pre>
|
|
TO FMT TO SEP Minimum Variable Length
|
|
---------------------- ------ -----------------------------
|
|
*JUL *NONE 5
|
|
*JUL Any 6
|
|
*MDY, *DMY, *YMD *NONE 6
|
|
*MDY, *DMY, *YMD Any 8
|
|
*MDYY, *DMYY, *YYMD *NONE 8
|
|
*MDYY, *DMYY, *YYMD Any 10
|
|
*CYMD *NONE 7
|
|
*CYMD Any 9
|
|
*LONGJUL *NONE 7
|
|
*LONGJUL Any 8
|
|
*ISO, *USA, *EUR, *JIS 10
|
|
*JOB Depends on job date format
|
|
*SYSVAL Depends on value of QDATFMT
|
|
</pre>
|
|
</p>
|
|
<p>
|
|
<pre>
|
|
Field Size
|
|
TO FMT Month Day Year
|
|
----------------------- ----- --- ----
|
|
*JUL N/A 3 2
|
|
*MDY, *DMY, *YMD 2 2 2
|
|
*MDYY, *DMYY, *YYMD 2 2 4
|
|
*ISO, *USA, *EUR, *JIS 2 2 4
|
|
*CYMD 2 2 2 (+1 byte century field)
|
|
</pre>
|
|
</p>
|
|
<p>This is a required parameter.
|
|
</p>
|
|
</div>
|
|
<table width="100%">
|
|
<tr><td align="right"><a href="#CVTDAT.Top_Of_Page">Top</a></td></tr>
|
|
</table>
|
|
<div> <a name="CVTDAT.FROMFMT"></a>
|
|
<h3>From date format (FROMFMT)</h3>
|
|
<p>Specifies the current format of the date to be converted.
|
|
</p>
|
|
<dl>
|
|
<dt><b><u>*JOB</u></b></dt>
|
|
<dd>The date has the format specified by the job attribute, DATFMT.
|
|
</dd>
|
|
<dt><b>*SYSVAL</b></dt>
|
|
<dd>The date has the format specified by the system value, QDATFMT.
|
|
</dd>
|
|
<dt><b>*MDY</b></dt>
|
|
<dd>The date has the month, day, year format, <b>mmddyy</b>.
|
|
</dd>
|
|
<dt><b>*MDYY</b></dt>
|
|
<dd>The date has the month, day, year format, <b>mmddyyyy</b>.
|
|
</dd>
|
|
<dt><b>*DMY</b></dt>
|
|
<dd>The date has the day, month, year format, <b>ddmmyy</b>.
|
|
</dd>
|
|
<dt><b>*DMYY</b></dt>
|
|
<dd>The date has the day, month, year format, <b>ddmmyyyy</b>.
|
|
</dd>
|
|
<dt><b>*YMD</b></dt>
|
|
<dd>The date has the year, month, day format, <b>yymmdd</b>.
|
|
</dd>
|
|
<dt><b>*YYMD</b></dt>
|
|
<dd>The date has the year, month, day format, <b>yyyymmdd</b>.
|
|
</dd>
|
|
<dt><b>*CYMD</b></dt>
|
|
<dd>The date has the century, year, month, day format, <b>cyymmdd</b>, where c is 0 for years 1928 through 1999 and is 1 for years 2000 through 2071.
|
|
</dd>
|
|
<dt><b>*JUL</b></dt>
|
|
<dd>The date has the Julian format, <b>yyddd</b>.
|
|
</dd>
|
|
<dt><b>*ISO</b></dt>
|
|
<dd>The date has the International Organization for Standardization (ISO) date format, <b>yyyy-mm-dd</b>.
|
|
</dd>
|
|
<dt><b>*USA</b></dt>
|
|
<dd>The date has the United States date format, <b>mm/dd/yyyy</b>.
|
|
</dd>
|
|
<dt><b>*EUR</b></dt>
|
|
<dd>The date has the European date format, <b>dd.mm.yyyy</b>.
|
|
</dd>
|
|
<dt><b>*JIS</b></dt>
|
|
<dd>The date has the Japanese Industrial Standard date format, <b>yyyy-mm-dd</b>.
|
|
</dd>
|
|
<dt><b>*LONGJUL</b></dt>
|
|
<dd>The date has the long Julian format, <b>yyyyddd</b>.
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
<table width="100%">
|
|
<tr><td align="right"><a href="#CVTDAT.Top_Of_Page">Top</a></td></tr>
|
|
</table>
|
|
<div> <a name="CVTDAT.TOFMT"></a>
|
|
<h3>To date format (TOFMT)</h3>
|
|
<p>Specifies the format to which the date is to be converted.
|
|
</p>
|
|
<dl>
|
|
<dt><b><u>*JOB</u></b></dt>
|
|
<dd>The date format is converted to the format specified by the job attribute, DATFMT.
|
|
</dd>
|
|
<dt><b>*SYSVAL</b></dt>
|
|
<dd>The date format is converted to the format specified by the system value, QDATFMT.
|
|
</dd>
|
|
<dt><b>*MDY</b></dt>
|
|
<dd>The date format is converted to the month, day, year format, <b>mmddyy</b>.
|
|
</dd>
|
|
<dt><b>*MDYY</b></dt>
|
|
<dd>The date format is converted to the month, day, year format, <b>mmddyyyy</b>.
|
|
</dd>
|
|
<dt><b>*DMY</b></dt>
|
|
<dd>The date format is converted to the day, month, year format, <b>ddmmyy</b>.
|
|
</dd>
|
|
<dt><b>*DMYY</b></dt>
|
|
<dd>The date format is converted to the day, month, year format, <b>ddmmyyyy</b>.
|
|
</dd>
|
|
<dt><b>*YMD</b></dt>
|
|
<dd>The date format is converted to the year, month, day format, <b>yymmdd</b>.
|
|
</dd>
|
|
<dt><b>*YYMD</b></dt>
|
|
<dd>The date format is converted to the year, month, day format, <b>yyyymmdd</b>.
|
|
</dd>
|
|
<dt><b>*CYMD</b></dt>
|
|
<dd>The date format is converted to the century, year, month, day format, <b>cyymmdd</b>, where c is 0 for years 1928 through 1999 and is 1 for years 2000 through 2071. If the year in the current format is only 2 digits, c will be set to 0 for years 40 through 99 and to 1 for years 00 through 39.
|
|
</dd>
|
|
<dt><b>*JUL</b></dt>
|
|
<dd>The date format is converted to the Julian format, <b>yyddd</b>.
|
|
</dd>
|
|
<dt><b>*ISO</b></dt>
|
|
<dd>The date format is converted to the International Organization for Standardization (ISO) date format, <b>yyyy-mm-dd</b>.
|
|
</dd>
|
|
<dt><b>*USA</b></dt>
|
|
<dd>The date format is converted to the United States date format, <b>mm/dd/yyyy</b>.
|
|
</dd>
|
|
<dt><b>*EUR</b></dt>
|
|
<dd>The date format is converted to the European date format, <b>dd.mm.yyyy</b>.
|
|
</dd>
|
|
<dt><b>*JIS</b></dt>
|
|
<dd>The date format is converted to the Japanese Industrial Standard date format, <b>yyyy-mm-dd</b>.
|
|
</dd>
|
|
<dt><b>*LONGJUL</b></dt>
|
|
<dd>The date has the long Julian format, <b>yyyyddd</b>.
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
<table width="100%">
|
|
<tr><td align="right"><a href="#CVTDAT.Top_Of_Page">Top</a></td></tr>
|
|
</table>
|
|
<div> <a name="CVTDAT.TOSEP"></a>
|
|
<h3>To date separator (TOSEP)</h3>
|
|
<p>Specifies the type of date separators (if any) used in the converted date.
|
|
</p>
|
|
<dl>
|
|
<dt><b><u>*JOB</u></b></dt>
|
|
<dd>The converted date has the separators specified by the job attribute, DATSEP.
|
|
</dd>
|
|
<dt><b>*SYSVAL</b></dt>
|
|
<dd>The converted date has the separators specified by the system value, QDATSEP.
|
|
</dd>
|
|
<dt><b>*NONE</b></dt>
|
|
<dd>No separator characters are contained in the converted date.
|
|
</dd>
|
|
<dt><b>*BLANK</b></dt>
|
|
<dd>A blank space is used as the date separator in the converted date.
|
|
</dd>
|
|
<dt><b><i>separator-character</i></b></dt>
|
|
<dd>Specify the character that is used as the date separator in the converted date. The valid separator characters are the slash (/), hyphen (-), period (.), and comma (,).
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
<table width="100%">
|
|
<tr><td align="right"><a href="#CVTDAT.Top_Of_Page">Top</a></td></tr>
|
|
</table>
|
|
<hr size="2" width="100%">
|
|
<div><h3><a name="CVTDAT.COMMAND.EXAMPLES">Examples</a> </h3>
|
|
<p><b>Example 1: Converting to DMY Format</b>
|
|
</p>
|
|
<p>
|
|
<pre>
|
|
DCL VAR(&DATE) TYPE(*CHAR) LEN(8)
|
|
:
|
|
CVTDAT DATE('12-24-88') TOVAR(&DATE) TOFMT(*DMY)
|
|
</pre>
|
|
</p>
|
|
<p>This command converts the date 12-24-88, which is in the MDY format. Because the FROMFMT parameter was not specified, its default, *JOB, indicates that the job attribute DATFMT contains the MDY format. The date is converted to the DMY format, and the separator character specified in the job attribute DATSEP is inserted. If DATSEP contains a slash, the converted result is 24/12/88.
|
|
</p>
|
|
<p><b>Example 2: Converting to Format Specified by Job Attribute</b>
|
|
</p>
|
|
<p>
|
|
<pre>
|
|
DCL &PAYDAY *CHAR 6
|
|
DCL &NEWPDAY *CHAR 6
|
|
:
|
|
CVTDAT DATE(&PAYDAY) TOVAR(&NEWPDAY)
|
|
FROMFMT(*YMD) TOSEP(*NONE)
|
|
</pre>
|
|
</p>
|
|
<p>This command converts the format of the date stored in &PAYDAY from year, month, day to the format specified by the job attribute DATFMT. If, for example, DATFMT contains the MDY format, the format of the converted date is month, day, and year. The converted date is stored in the variable &NEWPDAY. Because &NEWPDAY was declared as a 6-character variable, TOSEP(*NONE) is required; the converted result cannot include separator characters.
|
|
</p>
|
|
<p><b>Example 3: Converting to CYMD format</b>
|
|
</p>
|
|
<p>
|
|
<pre>
|
|
DCL &NEWDAY1 *CHAR 7
|
|
DCL &NEWDAY2 *CHAR 7
|
|
:
|
|
CVTDAT DATE('01/24/1939') TOVAR(&NEWDAY1)
|
|
FROMFMT(*MDYY) TOFMT(*CYMD) TOSEP(*NONE)
|
|
CVTDAT DATE('01/24/39') TOVAR(&NEWDAY2)
|
|
FROMFMT(*MDY) TOFMT(*CYMD) TOSEP(*NONE)
|
|
</pre>
|
|
</p>
|
|
<p>The first CVTDAT command converts the date specified on the DATE parameter from the month, day, 4-digit year format to the century, year, month, day format. Because the year was specified with 4 digits and the first 2 digits are "19", the century digit is set to "0", so the value of "NEWDAY1 is "0390124".
|
|
</p>
|
|
<p>The second CVTDAT command converts the date specified on the DATE parameter from the month, day, year format to the century, year, month, day format. Because the year was specified with only 2 digits and the year is less than 40, the century digit is set to "1", so the value of "NEWDAY2 is "1390124".
|
|
</p>
|
|
</div>
|
|
<table width="100%">
|
|
<tr><td align="right"><a href="#CVTDAT.Top_Of_Page">Top</a></td></tr>
|
|
</table>
|
|
<hr size="2" width="100%">
|
|
<div><h3><a name="CVTDAT.ERROR.MESSAGES">Error messages</a> </h3>
|
|
<p><b><u>*ESCAPE Messages</u></b>
|
|
</p>
|
|
<dl>
|
|
<dt><b>CPF0550</b></dt>
|
|
<dd>Date too short for specified format.
|
|
</dd>
|
|
<dt><b>CPF0551</b></dt>
|
|
<dd>Separators in date are not valid.
|
|
</dd>
|
|
<dt><b>CPF0552</b></dt>
|
|
<dd>Date contains misplaced or extra separators.
|
|
</dd>
|
|
<dt><b>CPF0553</b></dt>
|
|
<dd>Date contains too many or too few numeric characters.
|
|
</dd>
|
|
<dt><b>CPF0554</b></dt>
|
|
<dd>Variable specified too short for converted date format.
|
|
</dd>
|
|
<dt><b>CPF0555</b></dt>
|
|
<dd>Date not in specified format or date not valid.
|
|
</dd>
|
|
<dt><b>CPF0556</b></dt>
|
|
<dd>Date contains two or more kinds of separators.
|
|
</dd>
|
|
<dt><b>CPF0557</b></dt>
|
|
<dd>Date outside allowed range.
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
<table width="100%">
|
|
<tr><td align="right"><a href="#CVTDAT.Top_Of_Page">Top</a></td></tr>
|
|
</table>
|
|
</body>
|
|
</html>
|