

 Amazon Redshift non supporterà più la creazione di nuovi Python UDFs a partire dalla Patch 198. Python esistente UDFs continuerà a funzionare fino al 30 giugno 2026. Per ulteriori informazioni, consulta il [post del blog](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/). 

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Funzione TO\$1TIMESTAMP
<a name="r_TO_TIMESTAMP"></a>

TO\$1TIMESTAMP converte una stringa TIMESTAMP in TIMESTAMPTZ. Per un elenco di funzioni aggiuntive di data e ora per Amazon Redshift, consulta [Funzioni di data e ora](Date_functions_header.md).

## Sintassi
<a name="r_TO_TIMESTAMP-syntax"></a>

```
to_timestamp(timestamp, format)
```

```
to_timestamp (timestamp, format, is_strict)
```

## Arguments (Argomenti)
<a name="r_TO_TIMESTAMP-arguments"></a>

*timestamp*  
Una stringa che rappresenta un valore timestamp nel formato specificato da *format*. Se questo argomento viene lasciato vuoto, il valore del timestamp predefinito è `0001-01-01 00:00:00`.

*format*  
Una letterale di stringa che definisce il formato del valore *timestamp*. I formati che includono un fuso orario (**TZ**, **tz** o **OF**) non sono supportati come input. Per i formati di timestamp validi, consultare [Stringhe di formato datetime](r_FORMAT_strings.md).

*is\$1strict*  
Un valore booleano facoltativo che specifica se viene restituito un errore se un valore timestamp di input non è compreso nell'intervallo. Quando *is\$1strict* è impostato su TRUE, viene restituito un errore se esiste un valore fuori intervallo. Quando *is\$1strict* è impostato su FALSE, che è il valore di default, allora i valori di overflow sono accettati.

## Tipo restituito
<a name="r_TO_TIMESTAMP-return-type"></a>

TIMESTAMPTZ

## Esempi
<a name="r_TO_TIMESTAMP-examples"></a>

L'esempio seguente mostra l'utilizzo della funzione TO\$1TIMESTAMP per convertire una stringa TIMESTAMP in TIMESTAMPTZ. 

```
select sysdate, to_timestamp(sysdate, 'YYYY-MM-DD HH24:MI:SS') as second;

timestamp                  | second
--------------------------   ----------------------
2021-04-05 19:27:53.281812 | 2021-04-05 19:27:53+00
```

È possibile passare a TO\$1TIMESTAMP parte di una data. Le parti rimanenti della data sono impostate sui valori predefiniti. L'orario è incluso nell'output:

```
SELECT TO_TIMESTAMP('2017','YYYY');

to_timestamp
--------------------------
2017-01-01 00:00:00+00
```

L'istruzione SQL seguente converte la stringa '2011-12-18 24:38:15' in un TIMESTAMPTZ. Il risultato è un TIMESTAMPTZ che cade il giorno successivo perché il numero di ore è superiore a 24 ore:

```
SELECT TO_TIMESTAMP('2011-12-18 24:38:15', 'YYYY-MM-DD HH24:MI:SS');
         
to_timestamp
----------------------
2011-12-19 00:38:15+00
```

L'istruzione SQL seguente converte la stringa '2011-12-18 24:38:15' in un TIMESTAMPTZ. Il risultato è un errore perché il valore dell'ora nel timestamp è superiore a 24 ore:

```
SELECT TO_TIMESTAMP('2011-12-18 24:38:15', 'YYYY-MM-DD HH24:MI:SS', TRUE);
         
ERROR:  date/time field time value out of range: 24:38:15.0
```