$Sir Date2ND: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
m (link repair)
 
(30 intermediate revisions by 5 users not shown)
Line 2: Line 2:
<span class="pageSubtitle">Convert datetime string to number of days</span>
<span class="pageSubtitle">Convert datetime string to number of days</span>


<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Sir_Date2ND function is <var>[[StringToDays (String function)]]</var>.</p>
<p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Sir_Date2ND function is <var>[[StringToDays (String function)|StringToDays]]</var>.</p>


The <var>$Sir_Date2ND</var> function expects a datetime value string and a datetime format string and returns the input datetime converted to the number of days since 1 January, 1900. It accepts an optional CENTSPAN value and an optional error control string. If an error is detected, the returned value is <code>-9E12</code> (-9000000000000).


The $Sir_Date2ND function expects a datetime value string and a datetime format string and returns the input datetime converted to the number of days since 1 January, 1900. It accepts an optional CENTSPAN value and an optional error control string. If an error is detected, the returned value is -9E12 (-9000000000000).
==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %num = $Sir_Date2ND(dat, fmt, span, errctl)
<p class="syntax"><span class="term">%num</span> <span class="literal">= $Sir_Date2ND(</span><span class="term">dat</span><span class="literal">,</span> <span class="term">fmt</span><span class="literal">,</span> <span class="term">span</span><span class="literal">,</span> <span class="term">errctl</span><span class="literal">)</span>
<section end="syntax" /></p>
<p class="caption">$Sir_Date2ND Function
</p>
</p>
where
 
<table class="syntaxTable">
===Syntax terms===
<table>
<tr><th>%num</th>
<td>Set to the value of <var class="term">dat</var>, converted to the number of days from <code>1 Jan 1900 12:00 AM</code>.
</td></tr>
 
<tr><th>dat</th>
<tr><th>dat</th>
<td>datetime value string.</td></tr>
<td>Datetime value string.</td></tr>
 
<tr><th>fmt</th>
<tr><th>fmt</th>
<td>datetime format string corresponding to '''dat'''. Refer to for an explanation of valid datetime formats and valid dates. Non-strict matching is used for input format '''fmt'''; see .</td></tr>
<td>Datetime format string corresponding to <var class="term">dat</var>. Refer to [[Datetime string formats]] for an explanation of valid datetime formats and valid dates. Non-strict matching is used for input format <var class="term">fmt</var>; see [[Datetime string formats#Strict and non-strict format matching|Strict and non-strict format matching]].</td></tr>
 
<tr><th>span</th>
<tr><th>span</th>
<td>optional CENTSPAN value, default is -50. </td></tr>
<td>Optional <var>CENTSPAN</var> value, default is -50. </td></tr>
<tr><th>errctl</th>
<tr><th>errctl</th>
<td>optional error control string, refer to .</td></tr>
<td>Optional error control string; refer to [[Datetime string formats#Datetime error handling|Datetime error handling]].</td></tr>
<tr><th>%num</th>
</table>
<td>set to the value of '''dat''', converted to the number of days from 1 Jan 1900 12:00 AM.
</td></tr></table>


==Usage notes==
<ul>
<li>Values returned by <var>$Sir_Date2ND</var> can be stored in a <var>BINARY</var> or <var>FLOAT4</var> field, if you want.</li>


For example, the following fragment prints the value <tt>12</tt>:
<li>Dates prior to 1 January 1900 will return a negative number. </li>
<p class="code"> %A = $Sir_Date2ND('010695', 'MMDDYY')
%B = $Sir_Date2ND('122594', 'MMDDYY')
%C = %A - %B
PRINT %C
</p>
 


Error conditions are shown in the following figure (see the discussion in ).<p>
<li>The inverse of this $function is <var>[[$Sir_ND2Date]]</var>.</li>


<li><var>$Sir_Date2ND</var> returns the value <code>-9E12</code> (-9000000000000) in the following cases (see the discussion in [[Datetime string formats#Datetime error handling|Datetime error handling]]):
<ul>
<ul>
<li><var class="term">fmt</var> is not a valid datetime format.</li>


<li>'''fmt''' is not a valid datetime format.
<li><var class="term">dat</var> does not match <var class="term">fmt</var>.</li>


<li>'''dat''' does not match '''fmt'''.
<li><var class="term">dat</var> is outside of range permitted for <var class="term">fmt</var>.</li>


<li>'''dat''' is outside of range permitted for '''fmt'''.
<li><var class="term">span</var> is invalid.</li>
</ul></li>
</ul>


<li>'''span''' is invalid.
==Example==
The following fragment prints the value <code>12</code>:
<p class="code">%a = $Sir_Date2ND('010695', 'MMDDYY')
%b = $Sir_Date2ND('122594', 'MMDDYY')
%c = %a - %b
Print %c
</p>


</ul>
==Products authorizing {{PAGENAMEE}}==
</p>
<ul class="smallAndTightList">
<p class="caption"> $Sir_Date2ND returns the value -9E12 (-9000000000000) in the following cases:</p>
<li>[[List of $functions|Sirius functions]]</li>


<li>[[Fast/Unload User Language Interface]]</li>


Notes:
<li>[[Media:JoclrNew.pdf|Janus Open Client]]</li>
<ul>


<li>Values returned by $Sir_Date2ND can be stored in a BINARY or FLOAT4 field, if you wish.  
<li>[[Media:JosrvrNew.pdf|Janus Open Server]]</li>
<li>Dates prior to 1 January 1900 will return a negative number.
<li>The inverse of this $function is $Sir_ND2Date.
</ul>


<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Janus Open Client]]</li>
<li>[[Janus Open Server]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Japanese functions]]</li>
<li>[[Sir2000 Field Migration Facility]]</li>


<li>''[[Sir2000 User Language Tools]]''
<li>Japanese functions</li>
 
<li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li>
 
<li>[[Sir2000 User Language Tools]]</li>
</ul>
</ul>
<p class="caption">Products authorizing $Sir_Date2ND
</p>




[[Category:$Functions|$Sir_Date2ND]]
[[Category:$Functions|$Sir_Date2ND]]

Latest revision as of 22:52, 8 February 2018

Convert datetime string to number of days

Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Sir_Date2ND function is StringToDays.

The $Sir_Date2ND function expects a datetime value string and a datetime format string and returns the input datetime converted to the number of days since 1 January, 1900. It accepts an optional CENTSPAN value and an optional error control string. If an error is detected, the returned value is -9E12 (-9000000000000).

Syntax

%num = $Sir_Date2ND(dat, fmt, span, errctl)

Syntax terms

%num Set to the value of dat, converted to the number of days from 1 Jan 1900 12:00 AM.
dat Datetime value string.
fmt Datetime format string corresponding to dat. Refer to Datetime string formats for an explanation of valid datetime formats and valid dates. Non-strict matching is used for input format fmt; see Strict and non-strict format matching.
span Optional CENTSPAN value, default is -50.
errctl Optional error control string; refer to Datetime error handling.

Usage notes

  • Values returned by $Sir_Date2ND can be stored in a BINARY or FLOAT4 field, if you want.
  • Dates prior to 1 January 1900 will return a negative number.
  • The inverse of this $function is $Sir_ND2Date.
  • $Sir_Date2ND returns the value -9E12 (-9000000000000) in the following cases (see the discussion in Datetime error handling):
    • fmt is not a valid datetime format.
    • dat does not match fmt.
    • dat is outside of range permitted for fmt.
    • span is invalid.

Example

The following fragment prints the value 12:

%a = $Sir_Date2ND('010695', 'MMDDYY') %b = $Sir_Date2ND('122594', 'MMDDYY') %c = %a - %b Print %c

Products authorizing $Sir_Date2ND