Skip to content
Advertisement

choose from a time period oracle sql

I have timestamp date format in column FIRST_DATE and i need to choose time period from a certain hour, for ex. all from 18:00 10.05.21 to 18:00 11.05.2021

the problem is that date column in timestamp format – FIRST_DATE: 10/05/2020 0:00:03,000000 TIMESTAMP(6)

so i tried to use it:

so with this way i was able to limit the start period by time, but if i add date to this my conditions stop working

how can i correct my script to select all from 18:00 10.05.21 to 18:00 11.05.2021

Advertisement

Answer

Don’t compare dates (or timestamps) with strings. '18:00' and '10-MAY-21' are strings. Use TO_TIMESTAMP with appropriate format mask, e.g. (lines #5 and 6):

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement