1 year ago

#343587

test-img

Michaelle Sameer Ta Ani

Calculating the Difference in Days Between DATE occurrences

Trying to calculate a date difference beteween two occurrences in cases (date1 minus date2 minus 1), but get the following error: SELECT Failed. 3707: Syntax error, expected something like an 'END' keyword between ')' and the 'DAY' keyword.

Here is what i tried:

SELECT  BIFTA8_DT_ELAB, BIFTA8_FLAG_ELIMINA, 
BIFTA8_GRADO, BIFTA8_CODICE_COM,
BIFTA8_PROT, BIFTA8_DATA_ORA_UD, 
BIFTA8_SEZ, BIFTA8_TIPO_RICORR,
BIFTA8_PROG_RICORR, BIFTA8_UFFICIO, 
BIFTA8_DATA_USCITA, BIFTA8_ESITO_DEC,
BIFTA8_DATA_USCITA, BIFTA8_ESITO_DEC,
CASE WHEN MIN(DATA_USCITA)<TO_DATE('9999-12-31', 'YYYY-MM-DD') 
    THEN (BIFTA8_DATA_ORA_UD - MIN_DATA_USCITA) DAY -1 
    ELSE 0 END AS OUT_TEMPO_AVVISO,
CASE WHEN OUT_UDIENZA_SVOLTA='P' 
    AND MIN_DATA_USCITA=TO_DATE('9999-12-31', 'YYYY-MM-DD') 
    THEN (BIFTA8_DATA_ORA_UD - BIFTA8_DT_ELAB) DAY -1 
    ELSE 0 END AS OUT_TEMPO_ATTESA

sql

teradata

teradata-sql-assistant

date-difference

0 Answers

Your Answer

Accepted video resources