$DateCnv: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
m (minor cleanup)
Line 1: Line 1:
<p>The $DATECNV function converts an input date from its current format to a format you specify and, also, determines whether the input date is valid. If a format error occurs or the input date is not valid, the function returns all asterisks (*). $DATECNV supports both a 2- and a 4-digit year format; the year prefix can come from one of four places.</p>
<p>
<b>Syntax</b>
The $DATECNV function converts an input date from its current format to a format you specify and, also, determines whether the input date is valid. If a format error occurs or the input date is not valid, the function returns all asterisks (*). $DATECNV supports both a 2- and a 4-digit year format; the year prefix can come from one of four places.</p>
<p>The format of the $DATECNV function is:</p>
<p class="code">$DATECNV(input format,output format,input date,


        defcent, centsplt)  
===Syntax===
<p>
The format of the $DATECNV function is:</p>
<p class="syntax">$DATECNV(<span class="term">input format</span>, <span class="term">output format</span>, <span class="term">input date</span>, <span class="term">defcent</span>, <span class="term">centsplt</span>)  
</p>
</p>
<p>where:</p>
<p>
Where:</p>
<ul>
<ul>
<li>input format specifies the format of the input date. The format can be a combination of these elements:</li>
<li><var class="term">input format</var> specifies the format of the input date. The format can be a combination of these elements:
<table>
<table>
<tr>
<tr>
Line 14: Line 16:
<td>Gregorian numeric day</td>
<td>Gregorian numeric day</td>
</tr>
</tr>
<tr>
<tr>
<td>DDD</td>
<td>DDD</td>
<td>Julian numeric date</td>
<td>Julian numeric date</td>
</tr>
</tr>
<tr>
<tr>
<td>MM</td>
<td>MM</td>
<td>Numeric month</td>
<td>Numeric month</td>
</tr>
</tr>
<tr>
<tr>
<td>MON</td>
<td>MON</td>
<td>Abbreviated month name</td>
<td>Abbreviated month name</td>
</tr>
</tr>
<tr>
<tr>
<td>MONTH</td>
<td>MONTH</td>
<td>Full month name</td>
<td>Full month name</td>
</tr>
</tr>
<tr>
<tr>
<td>YY</td>
<td>YY</td>
<td>Last two digits of numeric year (assumes that the year prefix is 19)</td>
<td>Last two digits of numeric year (assumes that the year prefix is 19)</td>
</tr>
</tr>
<tr>
<tr>
<td>YYYY</td>
<td>YYYY</td>
<td>Full numeric year </td>
<td>Full numeric year </td>
</tr>
</tr>
<tr>
<tr>
<td>CYY</td>
<td>CYY</td>
Line 43: Line 52:
</tr>
</tr>
</table>
</table>
<p>Valid formats are:</p>
<p>
</li>
Valid formats are:</p>
</ul>
<p>A format that has a month, day, and year element</p>
<p>A format that has a month, day, and year element</p>
<p>A Julian date format that has a year element and a day element in the format DDD </p>
<p>A Julian date format that has a year element and a day element in the format DDD </p>
<p>Any EBCDIC characters except single quotes are allowed within the input format and appear unchanged in the output date. The input format can be as many as 32 characters in length. </p>
<p>Any EBCDIC characters except single quotes are allowed within the input format and appear unchanged in the output date. The input format can be as many as 32 characters in length. </p>
<p>When you use a 2-digit year, for example, YY is 98) in the input format and a 4-digit year (YYYY) in the output format, <var class="product">Model&nbsp;204</var> assumes that the century is 19-, for example, 1998.</p>
<p>When you use a 2-digit year, for example, YY is 98) in the input format and a 4-digit year (YYYY) in the output format, <var class="product">Model&nbsp;204</var> assumes that the century is 19-, for example, 1998.</p>
<ul>
 
<li>output format specifies the format of the output date. The format requirements are the same as those for the input format argument. Using a 2-digit year (YY) in the output format leaves you with no way to distinguish between centuries. For example:</li>
<li><var class="term">output format</var> specifies the format of the output date. The format requirements are the same as those for the input format argument. Using a 2-digit year (YY) in the output format leaves you with no way to distinguish between centuries. For example:
<p class="code">$DATECNV('MON DD, YYYY', 'YY DDD', 'JAN 10, 2005')
<p class="code">$DATECNV('MON DD, YYYY', 'YY DDD', 'JAN 10, 2005')
</p>
</p>
<p>produces the following output:</p>
<p>
produces the following output:</p>
<p class="code">05 010
<p class="code">05 010
</p>
</p>
<p>However, the output is exactly the same if the input date is January 10, 1905 or January 10, 2105.</p>
<p>
</li>
However, the output is exactly the same if the input date is January 10, 1905 or January 10, 2105.</p>
<li>input date specifies the input date in the format indicated by the input format argument. The input date can be as many as 36 characters in length.</li>
</li>
<li>defcent argument (optional) specifies the DEFCENT value to use; it overrides all other DEFCENT and CENTSPLT parameter values. This argument cannot be specified with the centsplt argument, unless one of the values is NULL. </li>
</li>
<li>centsplt argument (optional) specifies the CENTSPLT value to use; it overrides all other DEFCENT and CENTSPLT parameter values. This argument cannot be specified with the defcent argument, unless one of the values is NULL. </li>
</li>
</li>
<li><var class="term">input date</var> specifies the input date in the format indicated by the input format argument. The input date can be as many as 36 characters in length.</li>
<li><var class="term">defcent</var> (optional) specifies the DEFCENT value to use; it overrides all other DEFCENT and CENTSPLT parameter values. This argument cannot be specified with the centsplt argument, unless one of the values is NULL. </li>
<li><var class="term">centsplt</var> (optional) specifies the CENTSPLT value to use; it overrides all other DEFCENT and CENTSPLT parameter values. This argument cannot be specified with the defcent argument, unless one of the values is NULL. </li>
</ul>
</ul>
<p>The following example illustrates the use of the $DATECNV converting dates in various centuries.</p>
<p>
The following example shows the use of the $DATECNV converting dates in various centuries.</p>
<p class="code">PROCEDURE CENTSPLT
<p class="code">PROCEDURE CENTSPLT
BEGIN
BEGIN
Line 91: Line 102:
END PROCEDURE
END PROCEDURE
</p>
</p>
<p>For an explanation of the DEFCENT and CENTSPLT parameters processing see Rocket <var class="product">Model&nbsp;204</var> Parameter and Command Reference Manual in the chapter on parameters.</p>
<p>
<b>Separators and leading zeros</b>
For an explanation of the DEFCENT and CENTSPLT parameters processing see Rocket <var class="product">Model&nbsp;204</var> Parameter and Command Reference Manual in the chapter on parameters.</p>
<p>Use separators and leading zeros as specified here:</p>
===Separators and leading zeros===
<p>
Use separators and leading zeros as specified here:</p>
<ul>
<ul>
<li>Separators in the input format argument must match the separators in the input date argument. For example:</li>
<li>Separators in the input format argument must match the separators in the input date argument. For example:</li>
Line 99: Line 112:
       'JANUARY - 05 - 1990')  
       'JANUARY - 05 - 1990')  
</p></li>
</p></li>
<li>When necessary, you must pad the month or date in the input date argument with leading zeros to match the length of input format. For example:</li>
<li>When necessary, you must pad the month or date in the input date argument with leading zeros to match the length of input format. For example:</li>
<p class="code">$DATECNV('YY DDD','MON DD, YYYY','90 023')  
<p class="code">$DATECNV('YY DDD','MON DD, YYYY','90 023')  
</p></li>
</p></li>
</ul>
</ul>
<b>Example</b>
 
===Example===
<p class="code">PRINT $DATECNV('DDMMYY','MON DD, YYYY','010790')  
<p class="code">PRINT $DATECNV('DDMMYY','MON DD, YYYY','010790')  
</p>
</p>
<p>prints this value:</p>
<p>
prints this value:</p>
<p class="code">JUL 01, 1990   
<p class="code">JUL 01, 1990   
</p>
</p>
[[Category:SOUL $functions]]
[[Category:SOUL $functions]]

Revision as of 18:58, 14 April 2014

The $DATECNV function converts an input date from its current format to a format you specify and, also, determines whether the input date is valid. If a format error occurs or the input date is not valid, the function returns all asterisks (*). $DATECNV supports both a 2- and a 4-digit year format; the year prefix can come from one of four places.

Syntax

The format of the $DATECNV function is:

$DATECNV(input format, output format, input date, defcent, centsplt)

Where:

  • input format specifies the format of the input date. The format can be a combination of these elements:
    DD Gregorian numeric day
    DDD Julian numeric date
    MM Numeric month
    MON Abbreviated month name
    MONTH Full month name
    YY Last two digits of numeric year (assumes that the year prefix is 19)
    YYYY Full numeric year
    CYY The century, plus the year. Century (C) is a single digit, where 0 represents 1900, 1 represents 2000, and so on.

    Valid formats are:

    A format that has a month, day, and year element

    A Julian date format that has a year element and a day element in the format DDD

    Any EBCDIC characters except single quotes are allowed within the input format and appear unchanged in the output date. The input format can be as many as 32 characters in length.

    When you use a 2-digit year, for example, YY is 98) in the input format and a 4-digit year (YYYY) in the output format, Model 204 assumes that the century is 19-, for example, 1998.

  • output format specifies the format of the output date. The format requirements are the same as those for the input format argument. Using a 2-digit year (YY) in the output format leaves you with no way to distinguish between centuries. For example:

    $DATECNV('MON DD, YYYY', 'YY DDD', 'JAN 10, 2005')

    produces the following output:

    05 010

    However, the output is exactly the same if the input date is January 10, 1905 or January 10, 2105.

  • input date specifies the input date in the format indicated by the input format argument. The input date can be as many as 36 characters in length.
  • defcent (optional) specifies the DEFCENT value to use; it overrides all other DEFCENT and CENTSPLT parameter values. This argument cannot be specified with the centsplt argument, unless one of the values is NULL.
  • centsplt (optional) specifies the CENTSPLT value to use; it overrides all other DEFCENT and CENTSPLT parameter values. This argument cannot be specified with the defcent argument, unless one of the values is NULL.

The following example shows the use of the $DATECNV converting dates in various centuries.

PROCEDURE CENTSPLT BEGIN %INPUT_FORMAT = 'YYDDD' %OUTPUT_FORMAT = 'YYYY MM DD' %INPUT_VALUE = '9633' %CENTSPLT = 97 %DEFCENT = ' ' CALL PIT %CENTSPLT = ' ' %DEFCENT = 19 CALL PIT %INPUT_FORMAT = 'YYYYDDD' %INPUT_VALUE = '2006333' CALL PIT PIT: SUBROUTINE PRINT %INPUT_FORMAT ' ' %OUTPUT_FORMAT ' ' %INPUT_VALUE - ' ' %DEFCENT ' ' %CENTSPLT PRINT $DATECNV(%INPUT_FORMAT, %OUTPUT_FORMAT,%INPUT_VALUE, - %DEFCENT, %CENTSPLT) RETURN END SUBROUTINE END END PROCEDURE

For an explanation of the DEFCENT and CENTSPLT parameters processing see Rocket Model 204 Parameter and Command Reference Manual in the chapter on parameters.

Separators and leading zeros

Use separators and leading zeros as specified here:

  • Separators in the input format argument must match the separators in the input date argument. For example:
  • $DATECNV('MONTH - DD - YYYY','MON DD, YYYY', - 'JANUARY - 05 - 1990')

  • When necessary, you must pad the month or date in the input date argument with leading zeros to match the length of input format. For example:
  • $DATECNV('YY DDD','MON DD, YYYY','90 023')

Example

PRINT $DATECNV('DDMMYY','MON DD, YYYY','010790')

prints this value:

JUL 01, 1990