Conversion functions change data from one type to another to meet specific calculation needs or data format requirements. They ensure compatibility and correctness when you process data from different sources or formats. This topic describes how to use the built-in conversion functions.
BI_DATEFORMAT
BI_DATEFORMAT formats a date and returns it as a string.
Syntax | BI_DATEFORMAT(date, format) |
Parameters |
|
Definition | Formats a date and returns it as a string. |
Output | string |
Example | BI_DATEFORMAT('2020-09-29', 'yyyyMMdd') = '20200929' |
Limits | Not supported for Lindorm (LindormTSDB) data sources. |
BI_TODATE
BI_TODATE converts a string to a date.
Syntax | BI_TODATE(date_string, format) |
Parameters |
|
Definition | Parses the string <date_string> using the <format> pattern and returns a date. |
Output | date |
Example | BI_TODATE('2020-09-29', 'yyyy-MM-dd') = '2020-09-29' |
Limits | Supported only in Lindorm (LindormTable and multi-model SQL) data sources version 2.8 and later. |
BI_TODOUBLE
BI_TODOUBLE converts text or a number to a floating-point number.
Syntax | BI_TODOUBLE(expression) |
Parameter | expression: The text or number to convert. |
Definition | Converts text or a number to a floating-point number. |
Output | number |
Example | BI_TODOUBLE('123.21') = 123.21 BI_TODOUBLE(3) = 3.0 |
BI_TOINT
BI_TOINT converts text or a number to an integer.
Syntax | BI_TOINT(expression) |
Parameter description | expression: The text or number to convert. |
Definition | Converts text or a number to an integer. The function truncates any decimal part. |
Output | number |
Example | BI_TOINT('123.9') = 123 |
BI_TOSTR
BI_TOSTR converts a number to a string.
Syntax | BI_TOSTR(expression) |
Parameter description | expression: The value to wrap. |
Definition | Converts a number to a string. |
Output | string |
Example | BI_TOSTR(123) = '123' |