$DateChg: Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
m (misc cleanup)
 
Line 1: Line 1:
<p>The $DateChg function adds or subtracts a specified number of days from a given date. The result is returned in the format of the input date.</p>
<p>
<b>Syntax</b>
The <var>$DateChg</var> function adds or subtracts a specified number of days from a given date. The result is returned in the format of the input date.</p>
<p>The format of the $DateChg function is:</p>
 
<p class="code">$DateChg(format, date, number of days)  
==Syntax==
<p>
The format of the <var>$DateChg</var> function is:</p>
<p class="syntax">$DateChg(<span class="term">format, date, number-of-days</span>)  
</p>
</p>
<p>where:</p>
<p>Where:</p>
<ul>
<ul>
<li>format specifies the format of the input date. The format can be a combination of these elements:</li>
<li><var class="term">format</var> specifies the format of the input date. The format can be a combination of these elements:
<table>
<table class="thJustBold">
<tr>
<tr><th>DD</th>
<td>DD</td>
<td>Gregorian numeric day</td></tr>
<td>Gregorian numeric day</td>
 
</tr>
<tr><th>DDD</th>
<tr>
<td>Julian numeric date</td></tr>
<td>DDD</td>
 
<td>Julian numeric date</td>
<tr><th>MM</th>
</tr>
<td>Numeric month</td></tr>
<tr>
 
<td>MM</td>
<tr><th>MON</th>
<td>Numeric month</td>
<td>Abbreviated month name</td></tr>
</tr>
 
<tr>
<tr><th>MONTH</th>
<td>MON</td>
<td>Full month name</td></tr>
<td>Abbreviated month name</td>
 
</tr>
<tr><th>YY</th>
<tr>
<td>Last two digits of numeric year (assumes that the year prefix is 19)</td></tr>
<td>MONTH</td>
 
<td>Full month name</td>
<tr><th>YYYY</th>
</tr>
<td>Full numeric year </td></tr>
<tr>
 
<td>YY</td>
<tr><th>CYY</th>
<td>Last two digits of numeric year (assumes that the year prefix is 19)</td>
<td>The century, plus the year. Century (C) is a single digit, where 0 represents 1900, 1 represents 2000, and so on.</td></tr>
</tr>
<tr>
<td>YYYY</td>
<td>Full numeric year </td>
</tr>
<tr>
<td>CYY</td>
<td>The century, plus the year. Century (C) is a single digit, where 0 represents 1900, 1 represents 2000, and so on.</td>
</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 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 format. The format can be as many as 32 characters in length. </p>
<ul>
<ul>
<li>date specifies a date in the format indicated by the format argument. The date can be as many as 36 characters in length. </li>
<li>A format that has a month, day, and year element</li>
</li>
 
<li>number of days indicates the number of days to be added or deducted from the date. The number must be an integer. </li>
<li>A Julian date format that has a year element and a day element in the format <var>DDD</var> </li>
</li>
 
<li>Any EBCDIC characters except single quotes are allowed within the format. The format can be as many as 32 characters in length. </li>
</ul></li>
 
<li><var class="term">date</var> specifies a date in the format indicated by the format argument. The date can be as many as 36 characters in length. </li>
 
<li><var class="term">number-of-days</var> indicates the number of days to be added or deducted from the date. The number must be an integer. </li>
</ul>
</ul>
<b>Separators and leading zeros</b>
 
===Separators and leading zeros===
<ul>
<ul>
<li>The separators in the format argument must match the separators in the date argument. For example:</li>
<li>The separators in the format argument must match the separators in the date argument. For example:
<p class="code">$datechg('MONTH - DD - YYYY','JANUARY - 05 - 1986', 20)  
<p class="code">$datechg('MONTH - DD - YYYY','JANUARY - 05 - 1996', 20)  
</p></li>
</p></li>
<li>When necessary, you must pad the month or date in the date argument with leading zeros to match the length of the format. For example:</li>
<li>When necessary, you must pad the month or date in the date argument with leading zeros to match the length of the format. For example:</li>
<p class="code">$datechg('YY DDD','86 023',22)  
<p class="code">$datechg('YY DDD','96 023',22)  
</p></li>
</p></li>
</ul>
</ul>
<b>How $DateChg works</b>
 
==How $DateChg works==
<ul>
<ul>
<li>If the number of days is a positive integer, the number is added to the date.</li>
<li>If the number of days is a positive integer, the number is added to the date.</li>
</li>
 
<li>If number of days is a negative integer, the number is deducted from the date.</li>
<li>If number of days is a negative integer, the number is deducted from the date.</li>
</li>
 
<li>If an error occurs, all asterisks (*) are returned. </li>
<li>If an error occurs, all asterisks (<tt>*</tt>) are returned. </li>
</li>
</ul>
</ul>
<b>Example</b>
 
<p class="code">PRINT $datechg('MON. DD, YYYY','JAN. 10, 1999', 15)  
==Example==
The following statement:
<p class="code">Print $datechg('MON. DD, YYYY','JAN. 10, 2009', 15)  
</p>
</p>
<p>prints this value:</p>
<p>
<p class="code">JAN. 25, 1999    
Prints this value:</p>
<p class="output">JAN. 25, 2009    
</p>
</p>
[[Category:SOUL $functions]]
[[Category:SOUL $functions]]

Latest revision as of 20:36, 24 September 2015

The $DateChg function adds or subtracts a specified number of days from a given date. The result is returned in the format of the input date.

Syntax

The format of the $DateChg function is:

$DateChg(format, date, number-of-days)

Where:

  • 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 format. The format can be as many as 32 characters in length.
  • date specifies a date in the format indicated by the format argument. The date can be as many as 36 characters in length.
  • number-of-days indicates the number of days to be added or deducted from the date. The number must be an integer.

Separators and leading zeros

  • The separators in the format argument must match the separators in the date argument. For example:

    $datechg('MONTH - DD - YYYY','JANUARY - 05 - 1996', 20)

  • When necessary, you must pad the month or date in the date argument with leading zeros to match the length of the format. For example:
  • $datechg('YY DDD','96 023',22)

How $DateChg works

  • If the number of days is a positive integer, the number is added to the date.
  • If number of days is a negative integer, the number is deducted from the date.
  • If an error occurs, all asterisks (*) are returned.

Example

The following statement:

Print $datechg('MON. DD, YYYY','JAN. 10, 2009', 15)

Prints this value:

JAN. 25, 2009