$DateChg: Difference between revisions
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> | ||
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=" | ==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> | <p>Where:</p> | ||
<ul> | <ul> | ||
<li>format specifies the format of the input date. The format can be a combination of these elements: | <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>Gregorian numeric day</td></tr> | ||
<td>Gregorian numeric day</td> | |||
</tr> | <tr><th>DDD</th> | ||
<tr> | <td>Julian numeric date</td></tr> | ||
< | |||
<td>Julian numeric date</td> | <tr><th>MM</th> | ||
</tr> | <td>Numeric month</td></tr> | ||
<tr> | |||
< | <tr><th>MON</th> | ||
<td>Numeric month</td> | <td>Abbreviated month name</td></tr> | ||
</tr> | |||
<tr> | <tr><th>MONTH</th> | ||
< | <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>Full month name</td> | <tr><th>YYYY</th> | ||
</tr> | <td>Full numeric year </td></tr> | ||
<tr> | |||
< | <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>Full numeric year </td> | |||
</tr> | |||
<tr> | |||
< | |||
<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> | ||
Valid formats are:</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>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> | ||
===Separators and leading zeros=== | |||
<ul> | <ul> | ||
<li>The separators in the format argument must match the separators in the date argument. For example: | <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 - | <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',' | <p class="code">$datechg('YY DDD','96 023',22) | ||
</p></li> | </p></li> | ||
</ul> | </ul> | ||
==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>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>If an error occurs, all asterisks (*) are returned. | <li>If an error occurs, all asterisks (<tt>*</tt>) are returned. </li> | ||
</li> | |||
</ul> | </ul> | ||
<p class="code"> | ==Example== | ||
The following statement: | |||
<p class="code">Print $datechg('MON. DD, YYYY','JAN. 10, 2009', 15) | |||
</p> | </p> | ||
<p> | <p> | ||
<p class=" | 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