$Sir Date2N: Difference between revisions
Jump to navigation
Jump to search
m (add link) |
m (typo) |
||
Line 2: | Line 2: | ||
<span class="pageSubtitle">Convert datetime string to number of seconds/300</span> | <span class="pageSubtitle">Convert datetime string to number of seconds/300</span> | ||
<p class="warn"><b>Note: </b> | <p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented methods. There is currently no OO equivalent for the $Sir_Date2N function.</p> | ||
The <var>$Sir_Date2N</var> 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 <var>[[Datetime string formats#.24Sir_Datexxx CENTSPAN argument|CENTSPAN]]<var> value and an optional error control string. If an error is detected, the returned value is <code>-9E12</code> (-9000000000000). | The <var>$Sir_Date2N</var> 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 <var>[[Datetime string formats#.24Sir_Datexxx CENTSPAN argument|CENTSPAN]]<var> value and an optional error control string. If an error is detected, the returned value is <code>-9E12</code> (-9000000000000). |
Revision as of 18:17, 24 September 2015
Convert datetime string to number of seconds/300
Note: Many $functions have been deprecated in favor of Object Oriented methods. There is currently 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
%num = $Sir_Date2N(dat, fmt, span, errctl)
Syntax terms
%num | Set to the value of dat, converted to the number of 1/300th second units 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_Date2N 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 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