$Sir DateChg: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:$Sir_DateChg}} <span class="pageSubtitle">Add some days to datetime</span> <p class="warn"><b>Note:</b> This $function require the <var class="product">Media...")
 
m (link repair)
 
(9 intermediate revisions by the same user not shown)
Line 2: Line 2:
<span class="pageSubtitle">Add some days to datetime</span>
<span class="pageSubtitle">Add some days to datetime</span>


<p class="warn"><b>Note:</b> This $function require the <var class="product">[[Media:Ul2krNew.pdf|Sir2000 User Language Tools]]</var> product. </p>  
<p class="warn"><b>Note:</b> This $function require the <var class="product">[[Sir2000 User Language Tools]]</var> product. </p>  


<p>The <var>$Sir_DateChg</var> function expects a datetime format string,
<p>The <var>$Sir_DateChg</var> function expects a datetime format string,
a datetime value string, and a number of days.
a datetime value string, and a number of days.
It accepts an optional <var>CENTSPAN</var> value and an optional
It accepts an optional <var>[[Datetime string formats#Using CENTSPAN|CENTSPAN]]</var> value and an optional
error control string.
error control string.
It returns the datetime string obtained by adding the indicated number
It returns the datetime string obtained by adding the indicated number
Line 13: Line 13:
<p>
<p>
The <var>$Sir_DateChg</var> function is similar to the <var>[[$DateChg]]</var> function.
The <var>$Sir_DateChg</var> function is similar to the <var>[[$DateChg]]</var> function.
However, the <var>$DateChg</var> function does not support the specification of a <var>[[CENTSPLT parameter|CENTSPLT]]</var> or a
However, the <var>$DateChg</var> function does not support the specification of a <var>CENTSPAN</var> argument. </p>
<var>[[DEFCENT parameter|DEFCENT]]</var> argument. </p>


==Syntax==
==Syntax==
<p class="syntax"><span class="term">%odat</span> = $Sir_DateChg(<span class="term">fmt, dat, days, span, errctl</span>) </p>
<p class="syntax"><span class="term">%odat</span> = $Sir_DateChg(<span class="term">fmt</span>, <span class="term">dat</span>, <span class="term">days</span>, [<span class="term">span</span>], <span class="term">errctl</span>) </p>
Where:
Where:
<table>
<table>
<tr><th>%odat</th>
<td>Set to <var class="term">dat</var> plus <var class="term">days</var> 24-hour periods, unless an error is detected.</td></tr>
<tr><th>fmt</th>
<tr><th>fmt</th>
<td>Datetime format string, describes <i>dat</i> and <i>%odat</i>. Refer to [[Datetime string formats]] for an explanation of valid datetime formats and valid datetime values. Strict matching is used for <i>fmt</i>.</td></tr>
<td>Datetime format string, describes <i>dat</i> and <i>%odat</i>. Refer to [[Datetime string formats]] for an explanation of valid datetime formats and valid datetime values. [[Datetime string formats#Strict and non-strict format matching|Strict matching]] is used for <i>fmt</i>.</td></tr>


<tr><th>dat</th>
<tr><th>dat</th>
Line 34: Line 36:


<tr><th>errctl</th>
<tr><th>errctl</th>
<td>Optional error control string. Refer to [[Datetime string formats#Datetime error handling|Datetime error handling]].</td></tr>
<td>Optional error control string. Refer to [[The Sir2000 APPDATE command#Error handling control with DATE ERR|Error handling control with DATE_ERR]].</td></tr>
 
<tr><th>%odat</th>
<td>Set to <var class="term">dat</var> plus <var class="term">days</var> 24-hour periods, unless an error is detected.</td></tr>
</table>
</table>


Line 64: Line 63:
</ul>
</ul>
<p>
<p>
For more information about error handling, see the <var>[[APPDATE command|APPDATE]]</var> command, and see <var>[[Sir_Date_Err]]</var>. </p>
For more information about error handling, see [[Sir2000 User Language Tools $functions#Errors in datetime $functions|Errors in datetime $functions]]. </p>


[[Category:$Functions|$Sir_DateChg]]
[[Category:Sir2000 User Language Tools $functions]]

Latest revision as of 22:54, 8 February 2018

Add some days to datetime

Note: This $function require the Sir2000 User Language Tools product.

The $Sir_DateChg function expects a datetime format string, a datetime value string, and a number of days. It accepts an optional CENTSPAN value and an optional error control string. It returns the datetime string obtained by adding the indicated number of days to the input datetime; the return datetime string is in the same format as the input datetime string.

The $Sir_DateChg function is similar to the $DateChg function. However, the $DateChg function does not support the specification of a CENTSPAN argument.

Syntax

%odat = $Sir_DateChg(fmt, dat, days, [span], errctl)

Where:

%odat Set to dat plus days 24-hour periods, unless an error is detected.
fmt Datetime format string, describes dat and %odat. Refer to Datetime string formats for an explanation of valid datetime formats and valid datetime values. Strict matching is used for fmt.
dat Datetime value string.
days Number of days to add to dat.
span Optional CENTSPAN value, default is -50. Refer to Using CENTSPAN.
errctl Optional error control string. Refer to Error handling control with DATE_ERR.

Example

The following fragment prints the date one week after the run date:

%x = $sir_date('DAY Month, YYYY') Print $sir_datechg('DAY Month, YYYY', %x, 7)

Error conditions

$Sir_DateChg returns a string composed of all asterisks (*), whose length is the shorter of the length of the input date format string or 32, in the following error cases:

  • fmt is not a valid datetime format.
  • date does not match fmt or result date out of range.
  • days is omitted.
  • span contains an invalid CENTSPAN specification.

For more information about error handling, see Errors in datetime $functions.