prova questo,
ALTER SESSION SET NLS_DATE_FORMAT = 'MM/DD HH AM';
SELECT to_date('12/31/2017', 'MM/DD/YYYY') + (FLOOR(rownum/24) + (MOD(rownum-1, 24)/24)) dt
FROM DUAL
CONNECT BY rownum <= ((to_date('01/02/2018', 'MM/DD/YYYY')+(1/23)) - to_date('12/31/2017', 'MM/DD/YYYY') + (MOD(rownum, 24)/24)) * 24
ORDER BY 1;
Uscita:
DT
-----------
12/31 12 AM
12/31 01 AM
12/31 02 AM
12/31 03 AM
12/31 04 AM
12/31 05 AM
12/31 06 AM
12/31 07 AM
12/31 08 AM
12/31 09 AM
12/31 10 AM
12/31 11 AM
12/31 12 PM
12/31 01 PM
12/31 02 PM
12/31 03 PM
12/31 04 PM
12/31 05 PM
12/31 06 PM
12/31 07 PM
12/31 08 PM
12/31 09 PM
12/31 10 PM
01/01 12 AM
01/01 01 AM
01/01 02 AM
01/01 03 AM
01/01 04 AM
01/01 05 AM
01/01 06 AM
01/01 07 AM
01/01 08 AM
01/01 09 AM
01/01 10 AM
01/01 11 AM
01/01 12 PM
01/01 01 PM
01/01 02 PM
01/01 03 PM
01/01 04 PM
01/01 05 PM
01/01 06 PM
01/01 07 PM
01/01 08 PM
01/01 09 PM
01/01 10 PM
01/01 11 PM
01/02 12 AM
01/02 01 AM
01/02 02 AM
01/02 03 AM
01/02 04 AM
01/02 05 AM
01/02 06 AM
01/02 07 AM
01/02 08 AM
01/02 09 AM
01/02 10 AM
01/02 11 AM
01/02 12 PM
01/02 01 PM
01/02 02 PM
01/02 03 PM
01/02 04 PM
01/02 05 PM
01/02 06 PM
01/02 07 PM
01/02 08 PM
01/02 09 PM
01/02 10 PM
01/02 11 PM
71 righe selezionate
Se vuoi specificare l'ora di inizio e l'ora di fine, utilizza la query di seguito, ho appena modificato le clausole CONNECT BY e ORDER BY della mia prima query.
SELECT to_date('12/31/2017 10:00 PM', 'MM/DD/YYYY HH:MI AM') + (FLOOR(rownum/24) + (MOD(rownum-1, 24)/24)) dt
FROM DUAL
CONNECT BY rownum <= CEIL(((to_date('01/01/2018 02:00 AM', 'MM/DD/YYYY HH:MI AM') - to_date('12/31/2017 10:00 PM', 'MM/DD/YYYY HH:MI AM')) * 24))+1
ORDER BY rownum;
Uscita
DT
-----------
12/31 10 PM
12/31 11 PM
01/01 12 AM
01/01 01 AM
01/01 02 AM