LLMs.txt directory

Type conversion functions

Some formulas require the input to be of a particular data type. If you find that you want to pass a value to the function, but it is of the wrong data type, you can convert it using a conversion formula.

The following are the conversion formulas:

On SQL Server, Synapse, MySQL-family, SingleStore and ClickHouse connections, to_date functions are not currently supported.
Function Description Examples

to_bool

Returns the input as a boolean data type (true or false).

to_bool (0) = false
to_bool (married)

to_date

Converts a value to a date.

value

the text or integer to convert. Use a column, or a typed value such as '2026-10-29' or 20261029.

dateFormat

the pattern of the dates in value, written with the codes below in the same order as the parts of value. Separators between the parts, such as a hyphen (-), slash (/), dot (.), comma (,), colon (:), a space or no separator at all, must match value exactly. Include year, month and day; add time codes only if value also has a time.

Epoch values are not supported.

to_date('2026-10-29', '%Y-%m-%d')

to_date(20261029, '%Y%m%d')

to_date(column_name, '%m/%d/%Y'), where column_name is a text column with values like 10/29/2026

to_date('2026-10-29 14:05', '%Y-%m-%d %H:%M')

to_double

Returns the input as a double data type.

to_double ('3.14') = 3.14
to_double (revenue * .01)

to_integer

Returns the input as an integer.

to_integer ('45') + 1 = 46
to_integer (price + tax - cost)

to_string

Returns the input as a text string. To convert a date data type to a string data type, specify the date format you want to use in the second argument (for example, to_string ( <date column> , "%Y-%m-%d" )). Use strftime for the date format.

to_string (45 + 1) = '46'
to_string (revenue - cost)
to_string (date,'%m/%d/%y')

For to_date functions, we support the following codes:

Code Meaning Example

%Y

4-digit year

2026

%y

2-digit year

26

%m

2-digit month

05

%d

2-digit day

03

%b

abbreviated month name

Oct

%a

abbreviated weekday

Thu

%H / %I

2-digit hour, 24-hour / 12-hour

14 / 02

%M

2-digit minute

05

%S

2-digit second

09

Other strptime codes (for example %B, %j, %p) are not supported.

Any combination works. The codes can appear in any order, and each separator can differ, as long as the format follows the value. For example, to_date('12-02:2026', '%d-%m:%Y').

Pad numbers to their full width. Use 4-digit years with %Y, and 2-digit years, months, days and time parts. Values with no separators (20261029) require this, and some warehouses (for example, Databricks) reject single-digit parts such as 2026-5-3.

Two-digit years (%y): the warehouse decides the century, and the cutoff differs between warehouses. Prefer %Y.

Letters are not separators. For example, the T in 2026-10-29T14:05 is not supported.

Warehouse-native patterns are not supported. For example 'yyyymmdd' or 'YYYY-MM-DD'. They may appear to work on some connections but return wrong dates or errors on others: on Databricks and Denodo mm means minutes, and BigQuery accepts only % codes.