## Syntax ```mermaid %%{init: { 'theme': 'base', 'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' }, 'themeVariables': { 'fontSize': '11px', 'fontFamily': 'Arial' } }}%% flowchart LR Start((START)) --> TO_BOOLEAN[TO_BOOLEAN]:::quoted TO_BOOLEAN --> End((END)) ``` ## Purpose The `TO_BOOLEAN` SQL function casts a value into a `boolean`. Non-castable values raise an error; prevent such an error by first checking the value using [[IS_BOOLEAN]]. For numbers `0` is considered `false` and all other values `true`. All `datetime` are `false`. For texts, the following are considered `true`: `'true'`, `'t'`, `'yes'`, `'y'`, `'on'`, `'1'`, `'True'`, `'TRUE'`, `'T'`, `'YES'`, `'Y'` and `'ON'`. False are `'false'`, `'f'`, `'no'`, `'n'`, `'off'`, `'0'`, `'False'`, `'FALSE'`, `'F'`, `'NO'`, `'N'` and `'OFF'`. Parameters: - Input (`ANY`): value to cast. Returns: the input cast as a `boolean`. ## Examples The following example casts the text `'true'` to a boolean: ```sql select to_boolean('true') ---------------- true ``` The following example raises an error: ```sql select to_boolean('tr') ```