---
title: "TO_BOOLEAN"
description: "La funci\u00F3n SQL TO_BOOLEAN convierte un valor en un booleano."
language: es
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/es/docs/invantive-universalsql/grammar/sql-functions/to-boolean
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/to-boolean
updated: 2026-12-04T14:36:24Z
license: https://documentation.invantive.eu/es/
---

## Sintaxis
```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))
```

## Propósito
La función SQL `TO_BOOLEAN` convierte un valor en un `boolean`. Los valores no convertibles provocan un error; para evitarlo, compruebe primero el valor utilizando [[IS_BOOLEAN]].

Para números, `0` se considera `false` y todos los demás valores `true`. Todos los `datetime` son `false`. Para textos, se consideran `true`: `'true'`, `'t'`, `'yes'`, `'y'`, `'on'`, `'1'`, `'True'`, `'TRUE'`, `'T'`, `'YES'`, `'Y'` y `'ON'`. False are `'false'`, `'f'`, `'no'`, `'n'`, `'off'`, `'0'`, `'False'`, `'FALSE'`, `'F'`, `'NO'`, `'N'` and `'OFF'`.

Parámetros:
- Entrada (`ANY`): valor que se va a convertir.

Devuelve: el valor de entrada convertido a un `boolean`.

## Ejemplos
En el siguiente ejemplo, se convierte el texto `'true'` en un `boolean`:
```sql
select to_boolean('true')

----------------
true
```
El siguiente ejemplo genera un error:
```sql
select to_boolean('tr')

itgendid068: Invalid boolean value 'tr'.
```

