---
title: "TO_BOOLEAN"
description: "La funzione SQL TO_BOOLEAN converte un valore in un booleano."
language: it
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/it/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:30Z
license: https://documentation.invantive.eu/it/
---

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

## Scopo
La funzione SQL `TO_BOOLEAN` converte un valore in un `boolean`. I valori non convertibili generano un errore; per evitare tale errore, verificare prima il valore utilizzando [[IS_BOOLEAN]].

Per i numeri, `0` è considerato `false` e tutti gli altri valori `true`. Tutti gli `datetime` sono `false`. Per i testi, sono considerati `true` i seguenti: `'true'`, `'t'`, `'yes'`, `'y'`, `'on'`, `'1'`, `'True'`, `'TRUE'`, `'T'`, `'YES'`, `'Y'` e `'ON'`. False are `'false'`, `'f'`, `'no'`, `'n'`, `'off'`, `'0'`, `'False'`, `'FALSE'`, `'F'`, `'NO'`, `'N'` and `'OFF'`.

Parametri:
- Input (`ANY`): valore da convertire.

Restituisce: l’input convertito in un `boolean`.

## Esempi
L'esempio seguente converte il testo `'true'` in `boolean`:
```sql
select to_boolean('true')

----------------
true
```
L'esempio seguente genera un errore:
```sql
select to_boolean('tr')

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

