ibm-information-center/dist/eclipse/plugins/i5OS.ic.rbam6_5.4.0.1/convd.htm

159 lines
9.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="task" />
<meta name="DC.Title" content="QDATE system value" />
<meta name="abstract" content="In many applications, you may want to use the current date in your procedure by retrieving the system value QDATE and placing it in a variable. You may also want to change the format of that date for use in your procedure." />
<meta name="description" content="In many applications, you may want to use the current date in your procedure by retrieving the system value QDATE and placing it in a variable. You may also want to change the format of that date for use in your procedure." />
<meta name="DC.subject" content="converting, date format, format of date, date, converting format, CVTDAT (Convert Date) command, Convert Date (CVTDAT) command, command, CL, CVTDAT (Convert Date), Convert Date (CVTDAT), example, converting system value, CEELOCT program, Get Current Local Time (CEELOCT)" />
<meta name="keywords" content="converting, date format, format of date, date, converting format, CVTDAT (Convert Date) command, Convert Date (CVTDAT) command, command, CL, CVTDAT (Convert Date), Convert Date (CVTDAT), example, converting system value, CEELOCT program, Get Current Local Time (CEELOCT)" />
<meta name="DC.Relation" scheme="URI" content="retsv.htm" />
<meta name="DC.Relation" scheme="URI" content="../apiref/api.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="convd" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>QDATE system value</title>
</head>
<body id="convd"><a name="convd"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">QDATE system value</h1>
<div><p>In many applications, you may want to use the current date in your
procedure by retrieving the system value QDATE and placing it in a variable.
You may also want to change the format of that date for use in your procedure. </p>
<div class="section"> <p>To convert the format of a date in a CL procedure, use the <span class="cmdname">Convert
Date (CVTDAT)</span> command.</p>
<p>The format for the system date is the
system value QDATFMT. The shipped value of QDATFMT varies according to country
or region. For example, <samp class="codeph">062488</samp> is the MDY (monthdayyear)
format for June 24 1988. You can change this format to the YMD, DMY, or the
JUL (Julian) format. For Julian, the QDAY value is a 3-character value from
001 to 366. It is used to determine the number of days between two dates.
You can also delete the date separators or change the character used as a
date separator with the <span class="cmdname">Convert Date (CVTDAT)</span> command.</p>
<p>The
format for the <span class="cmdname">Convert Date (CVTDAT)</span> command is: </p>
<pre>CVTDAT DATE(date-to-be-converted) TOVAR(CL-variable) +
FROMFMT(old-format) TOFMT(new-format) +
TOSEP(new-separators)</pre>
<p>The DATE parameter can specify a constant or a variable to
be converted. Once the date has been converted, it is placed in the variable
named on the TOVAR parameter. In the following example, the date in variable &amp;DATE,
which is formatted as MDY, is changed to the DMY format and placed in the
variable &amp;CVTDAT. </p>
<pre>CVTDAT DATE(&amp;DATE) TOVAR(&amp;CVTDAT) FROMFMT(*MDY) TOFMT(*DMY)
TOSEP(*SYSVAL)</pre>
<p>The date separator remains as specified in the system value
QDATSEP.</p>
<p>The <span class="cmdname">Convert Date (CVTDAT)</span> command can be
useful when creating objects or adding a member that uses a date as part of
its name. For example, assume that a member must be added to a file using
the current system date. Also, assume that the current date is in the MDY
format and is to be converted to the Julian format. </p>
<pre>PGM
DCL &amp;DATE6 *CHAR LEN(6)
DCL &amp;DATE5 *CHAR LEN(5)
RTVSYSVAL QDATE RTNVAR(&amp;DATE6)
CVTDAT DATE(&amp;DATE6) TOVAR(&amp;DATE5) TOFMT(*JUL) TOSEP(*NONE)
ADDPFM LIB1/FILEX MBR('MBR' *CAT &amp;DATE5)
.
.
.
ENDPGM</pre>
<p>If the current date is 5 January 1988, the added member would
be named MBR88005.</p>
<p>Remember the following when converting dates: </p>
<ul><li>The length of the value in the DATE parameter and the length of the variable
on the TOVAR parameter must be compatible with the date format. The length
of the variable on the TOVAR parameter must be at least:</li>
<li> <ol><li>For Non-Julian Dates possessing 2 digit years <ol type="a"><li>Use 6 characters when using no separators. <pre>July 28, 1978 would be written as 072878.</pre>
</li>
<li>Use 8 characters when using separators. <pre>July 28, 1978 would be written as 07-28-78.</pre>
</li>
</ol>
</li>
<li>For Non-Julian Dates with 4digit years <ol type="a"><li>Use 8 characters when using no separators. <pre>July 28, 1978 would be written as 07281978.</pre>
</li>
<li>Use 10 characters when using separators. <pre>July 28, 1978 would be written as 07-28-1978.</pre>
</li>
</ol>
</li>
<li>For Julian dates with 2digit years <ol type="a"><li>Use 5 characters when using no separators. <pre>December 31, 1996 would be written as 96365.</pre>
</li>
<li>Use 6 characters when using separators. <pre>December 31, 1996 would be written as 96-365.</pre>
</li>
</ol>
</li>
<li>For Julian dates with 4digit years, <ol type="a"><li>7 characters are required when no separators are used. <pre>February 4, 1997 would be written as 1997035.</pre>
</li>
<li>8 characters are required when separators are used. <pre>February 4, 1997 would be written as 1997-035.</pre>
</li>
</ol>
</li>
</ol>
<p>Error messages are sent for converted characters that do not fit
in the variable. If the converted date is shorter than the variable, it is
padded on the right with blanks.</p>
</li>
<li>In every date format except Julian, the month and day are 2-byte fields
no matter what value they contain. The year may be either 2-byte or 4-byte
fields. All converted values are right-justified and, when necessary, padded
with leading zeros.</li>
<li>In the Julian format, day is a 3-byte field, and year is a 2-byte or 4-byte
field. All converted values are right-justified and, when necessary, padded
with leading zeros.</li>
</ul>
<p>The following is an alternative program that uses the ILE bindable
API, Get Current Local Time (CEELOCT), to convert a date to Julian format.
To create this program, you must use the <span class="cmdname">Create Bound Control Language
Program (CRTBNDCL)</span> command alone, or the <span class="cmdname">Create Control
Language Module (CRTCLMOD)</span> command and the <span class="cmdname">Create Program
(CRTPGM)</span> command together. </p>
<pre>PGM
DCL &amp;LILDATE *INT LEN(4)
DCL &amp;PICTSTR *CHAR LEN(5) VALUE(YYDDD)
DCL &amp;JULDATE *CHAR LEN(5)
DCL &amp;SECONDS *CHAR 8 /* Seconds from CEELOCT */
DCL &amp;GREG *CHAR 23 /* Gregorian date from CEELOCT */
/* */
CALLPRC PRC(CEELOCT) /* Get current date and time */ +
PARM(&amp;LILDATE /* Date in Lilian format */ +
&amp;SECONDS /* Seconds field will not be used */ +
&amp;GREG /* Gregorian field will not be used */ +
*OMIT) /* Omit feedback parameter */ +
/* so exceptions are signalled */
CALLPRC PRC(CEEDATE) +
PARM(&amp;LILDATE /* Today's date */ +
&amp;PICTSTR /* How to format */ +
&amp;JULDATE /* Julian date */ +
*OMIT)
ADDPFM LIB1/FILEX MBR('MBR' *CAT &amp;JULDATE')
ENDPGM</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="retsv.htm" title="A system value contains control information for the operation of certain parts of the system.">Retrieve system values</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../apiref/api.htm">Application Programming Interfaces (API)</a></div>
</div>
</div>
</body>
</html>