$Sir Date2N: Difference between revisions
m (1 revision) |
m (→Syntax) |
||
Line 9: | Line 9: | ||
<p class="syntax"><section begin="syntax" /> %num = $Sir_Date2N(dat, fmt, span, errctl) | <p class="syntax"><section begin="syntax" /> %num = $Sir_Date2N(dat, fmt, span, errctl) | ||
<section end="syntax" /></p> | <section end="syntax" /></p> | ||
===Syntax terms=== | |||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
Line 18: | Line 16: | ||
<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 | <td>datetime format string corresponding to <var class="term">dat</var>. Refer to [[Datetime string formats|"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 CENTSPAN 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 | <td>set to the value of <var class="term">dat</var>, converted to the number of 1/300th second units from 1 Jan 1900 12:00 AM. | ||
</td></tr> | </td></tr> | ||
</table> | </table> | ||
==Usage notes== | |||
<ul> | <ul> | ||
<li>Values returned by $Sir_Date2N 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>Values returned by $Sir_Date2N 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>Dates prior to 1 January 1900 will return a negative number. | ||
<li>The inverse of this $function is $Sir_N2Date. | <li>The inverse of this $function is $Sir_N2Date. | ||
<li><var>$Sir_Date2N</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> | |||
<li><var class="term">fmt</var> is not a valid datetime format. | |||
<li><var class="term">dat</var> does not match '''fmt'''. | |||
<li><var class="term">dat</var> is outside of range permitted for '''fmt'''. | |||
<li><var class="term">span</var> is invalid. | |||
</ul> | |||
</ul> | </ul> | ||
==Example== | |||
The following fragment prints the value <code>Before</code>: | |||
<p class="code">If $Sir_Date2N('121494', 'MMDDYY') < $Sir_Date2N('040195', 'MMDDYY') Then | |||
Print 'Before' | |||
End If | |||
</p> | |||
<ul class="smallAndTightList"> | <ul class="smallAndTightList"> |
Revision as of 20:43, 8 February 2012
Convert datetime string to number of seconds/300
Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currentyly no OO equivalent for the $Sir_Date2N function.
The $Sir_Date2N function expects a datetime value string and a datetime format string and returns the input datetime converted to the number of 1/300th seconds 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_Date2N(dat, fmt, span, errctl) <section end="syntax" />
Syntax terms
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". |
%num | set to the value of dat, converted to the number of 1/300th second units from 1 Jan 1900 12:00 AM. |
Usage notes
- Values returned by $Sir_Date2N 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_N2Date.
- $Sir_Date2N 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 Before
:
If $Sir_Date2N('121494', 'MMDDYY') < $Sir_Date2N('040195', 'MMDDYY') Then Print 'Before' End If