TO_DATE
Sintassi
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> TO_DATE[TO_DATE]:::quoted
TO_DATE --> End((END))
Scopo
La funzione SQL TO_DATE converte un valore in un datetime. I valori non convertibili generano un errore; per evitare tale errore, verificare prima il valore utilizzando IS_DATE.
Parametri:
- Input (
ANY): valore da convertire indatetime, se possibile. - Formato (facoltativo,
varchar2): maschera di formato, ad esempioDD-MON-YYYY HH24:MI. Il valore predefinito è il formato data/ora configurato. Gli elementi di una maschera di formato sono descritti in Format Masks; qualsiasi combinazione di elementi è disponibile a partire dalla versione 28.0.
Restituisce: l’input convertito in un datetime.
Esempi
L'esempio seguente converte '20190101' in datetime utilizzando una maschera di formato:
select to_date('20190101', 'YYYYMMDD')
--------------------
01-01-2019 00:00:00
L'esempio seguente converte un testo contenente il nome di un mese e un'ora senza secondi in un datetime:
select to_date('13-Aug-2026 12:34', 'DD-MON-YYYY HH24:MI')
--------------------
13-08-2026 12:34:00
L'esempio seguente converte un testo ISO 8601 in un datetime utilizzando il formato predefinito:
select to_date('2016-12-31T12:34:56')
--------------------
31-12-2016 12:34:56