Conversion functions
- Last UpdatedDec 19, 2022
- 2 minute read
The RTQP Engine supports conversion functions, which change an expression from one data type to another. These functions are similar to the CAST expression, but some have additional arguments that expand the conversion functionality.
The function name is the resulting data type. For example, if you want to convert data to string data type, you would use .
If you can change the data type using CAST, you can use the corresponding conversion function. Most of conversion functions use a single argument and are straightforward in their use. Those functions are not documented further. Functions that require multiple arguments or additional explanation are documented here.
DOUBLE with TimeSpan
Use the DOUBLE function to convert a TimeSpan (x) to a floating-point number that represents the number of date/time units (timeUnit). The following are valid values for the TimeUnit enumeration: day, hour, minute, second, millisecond, microsecond, or nanosecond.
DOUBLE(x TimeSpan, y TimeUnit)
For example, returns and returns .
TIMESPAN with Double
Use the TIMESPAN function to convert a double (x) to a TimeSpan using the specified date/time units (timeUnit). The following are valid values for the TimeUnit enumeration: day, hour, minute, second, millisecond, microsecond, or nanosecond.
TIMESPAN(x Double, y TimeUnit)
For example, returns and returns .
INT64 with TimeSpan
Use the INT64 function to convert a TimeSpan (timeSpan) to an integer that represents the number of ticks. A tick equals 100 nanoseconds or one ten-millionth of a second. To ensure the function interprets the value as a TimeSpan, wrap the value in the TimeSpan function.
INT64(TimeSpan(timeSpan TimeSpan))
For example, returns .
TIMESPAN with Int64
Use the function to convert an Int64 (n) that represents the number of ticks to a TimeSpan. A tick equals 100 nanoseconds or one ten-millionth of a second.
TIMESPAN(n Int64)
For example, returns .
TIMESPAN with String
Use the function to convert a String (s) to a TimeSpan.
TIMESPAN(s String)
The following formats for the String are supported:
{+|-}<number>[.<number>] <interval> { [+|-]<number>[.<number>] <interval> }*
or
{+|-}{ hh | [hh][:[mm][:ss[.ff]]] }
or
[-]d.hh:mm[:ss[.ff]]
For full details about the first two formats, see the Remarks section of the AF SDK Reference page AFTimeSpan.Parse Method (String, IFormatProvider).
For example, returns .
TIMEPERIOD with String
Use the function to convert a String (s) to a TimePeriod.
TIMEPERIOD(s String)
The following formats for the String are supported:
<number>[.<number>] <interval> { <number>[.<number>] <interval> }*
or
{ hh | [hh][:[mm][:ss[.ff]]] }
or
d.hh:mm[:ss[.ff]]
For full details about the first two formats, see the Remarks section of the AF SDK Reference page AFTimeSpan.Parse Method (String, IFormatProvider).
For example, returns .