$Sir Date2NM: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 4: Line 4:
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currently no OO equivalent for the $Sir_Date2NM function.</p>
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currently no OO equivalent for the $Sir_Date2NM function.</p>


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


==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %num = $Sir_Date2NM(dat, fmt, span, errctl)
<p class="syntax"><section begin="syntax" /> %num = $Sir_Date2NM(dat, fmt, span, errctl)
<section end="syntax" /></p>
<section end="syntax" /></p>
<p class="caption">$Sir_Date2NM Function
</p>
where


===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<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 [[Datetime string formats|datetime formats]] 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|datetime 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>
<tr><th>%num</th>
<td>set to the value of '''dat''', converted to the number of milliseconds from 1 Jan 1900 12:00 AM.
<td>Set to the value of <var class="term">dat</var>, converted to the number of milliseconds from 1 Jan 1900 12:00 AM.
</td></tr>
</td></tr>
</table>
</table>


For example, the following fragment prints the value <tt>86400000</tt>:
==Usage notes==
 
<ul>
<p class="code"> %A = $Sir_Date2NM('010695', 'MMDDYY')
<li>Values returned by $Sir_Date2NM will often exceed the range that can be represented in a 4-byte integer, so you should probably avoid storing the value in a <var>BINARY</var> or <var>FLOAT4</var> field.
%B = $Sir_Date2NM('010595', 'MMDDYY')
<li>Dates prior to 1 January 1900 will return a negative number.
%C = %A - %B
<li>The inverse of this $function is <var>[[$Sir_NM2Date]]</var>.
PRINT %C
<li><var>$Sir_Date2NM</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"]]):
</p>
 
Error conditions are shown in the following figure (see the discussion in ).
<ul>
<ul>
<li>'''fmt''' is not a valid datetime format.
<li><var class="term">fmt</var> is not a valid datetime format.
<li>'''dat''' does not match '''fmt'''.
<li><var class="term">dat</var> does not match <var class="term">fmt</var>.
<li>'''dat''' is outside of range permitted for '''fmt'''.
<li><var class="term">dat</var> is outside of range permitted for <var class="term">fmt</var>.
<li>'''span''' is invalid.
<li><var class="term">span</var> is invalid.
</ul>
</ul>


<p class="caption"> $Sir_Date2NM returns the value -9E12 (-9000000000000) in the following cases:</p>
<p class="caption"> </p>
 
Notes:
 
<ul>
<li>Values returned by $Sir_Date2NM will often exceed the range that can be represented in a 4-byte integer, so you should probably avoid storing the value in a BINARY or FLOAT4 field.
<li>Dates prior to 1 January 1900 will return a negative number.
<li>The inverse of this $function is $Sir_NM2Date.
</ul>
</ul>



Revision as of 22:17, 8 February 2012

Convert datetime string to number of milliseconds

Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currently no OO equivalent for the $Sir_Date2NM function.

The $Sir_Date2NM function expects a datetime value string and a datetime format string and returns the input datetime converted to the number of milliseconds 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

<section begin="syntax" /> %num = $Sir_Date2NM(dat, fmt, span, errctl) <section end="syntax" />

Syntax terms

dat Datetime value string.
fmt Datetime format string corresponding to dat. Refer to datetime 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".
%num Set to the value of dat, converted to the number of milliseconds from 1 Jan 1900 12:00 AM.

Usage notes

  • Values returned by $Sir_Date2NM will often exceed the range that can be represented in a 4-byte integer, so you should probably avoid storing the value in a BINARY or FLOAT4 field.
  • Dates prior to 1 January 1900 will return a negative number.
  • The inverse of this $function is $Sir_NM2Date.
  • $Sir_Date2NM 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.

Products authorizing $Sir_Date2NM