$DateChg: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
<p>The $ | <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> | ||
<b>Syntax</b> | <b>Syntax</b> | ||
<p>The format of the $ | <p>The format of the $DateChg function is:</p> | ||
<p class="code">$ | <p class="code">$DateChg(format, date, number of days) | ||
</p> | </p> | ||
<p>where:</p> | <p>where:</p> | ||
Line 56: | Line 56: | ||
<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:</li> | ||
<p class="code">$ | <p class="code">$datechg('MONTH - DD - YYYY','JANUARY - 05 - 1986', 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">$ | <p class="code">$datechg('YY DDD','86 023',22) | ||
</p></li> | </p></li> | ||
</ul> | </ul> | ||
<b>How $ | <b>How $DateChg works</b> | ||
<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> | ||
Line 72: | Line 72: | ||
</ul> | </ul> | ||
<b>Example</b> | <b>Example</b> | ||
<p class="code">PRINT $ | <p class="code">PRINT $datechg('MON. DD, YYYY','JAN. 10, 1999', 15) | ||
</p> | </p> | ||
<p>prints this value:</p> | <p>prints this value:</p> |
Revision as of 14:26, 16 July 2014
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:
- 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('MONTH - DD - YYYY','JANUARY - 05 - 1986', 20)
$datechg('YY DDD','86 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
PRINT $datechg('MON. DD, YYYY','JAN. 10, 1999', 15)
prints this value:
JAN. 25, 1999