Mendix 7 is no longer supported unless you have Extended Support (for details, please contact Mendix Support). Mendix 7 documentation will remain available for customers with Extended Support until July, 2024.

OQL CAST

Last modified: February 7, 2024

1 Introduction

The CAST function converts an expression to a specific data type.

The syntax is as follows:

CAST ( expression AS data_type )
  • expression – specifies the expression to convert
  • data_type – specifies the data type to convert the expression to; the data type can be one of the following:
    • BOOLEAN
    • DATETIME
    • DECIMAL
    • FLOAT (deprecated)
    • INTEGER
    • LONG
    • STRING

2 Supported Conversions

The table below describes which CAST conversions are supported:

  • ✔ – the conversion is supported
  • ✔* – the conversion is supported, but the behavior differs per database (see remarks below)
  • ✘ – the conversion is not supported
From \ To BOOLEAN DATETIME DECIMAL INTEGER FLOAT LONG STRING (unlimited) STRING (limited)
BOOLEAN ✔* ✔*1
DATETIME ✔* ✔*2
DECIMAL ✔* ✔* ✔* ✔* ✔* ✔*2
INTEGER
FLOAT ✔* ✔*2
LONG
STRING

[1] BOOLEAN to STRING (limited) is supported only if the resulting string length is ≥ 5.
[2] The conversion of DATETIME, DECIMAL, and FLOAT to STRING (limited) is supported only if the value fully fits into the string length. The conversion can fail if the resulting string length is less than 20.