Type conversion functions

Learn about data 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:

to_bool

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

Examples
to_bool (0) = false
to_bool (married)
to_date

Accepts a date represented as an integer or text string, and a second string parameter that can include strptime date formatting elements.

Replaces all the valid strptime date formatting elements with their string counterparts and returns the result.

Does not accept epoch-formatted dates as input.

Does not accept datetime values. Only accepts month, day, and year.

Examples
to_date (date_sold, '%Y-%m-%d')
to_double

Returns the input as a double data type.

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

Returns the input as an integer.

Examples
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.

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