Skip to content
Advertisement

Limit date for each day to 2:30 PM

SQL Oracle Query:

I have datetime values in 30 minute intervals. I want to stop each day at 2:30 PM.

I am limiting my hours with this:

TO_CHAR(ALL_DATES.DATEDATE,'HH24') NOT IN (01,02,03,04,05,06,07,17,18,19,20,21,22,23,00)

This gives me data from 8 AM to 3 PM. I need to only have data through 2:30.
Please show me how to do this better.

Advertisement

Answer

Plain Standard SQL, but Oracle chokes on DATEs.

TIMESTAMP datatype:

cast(ALL_DATES.DATEDATE as time) between time '08:00:00' and time '14:30:00'

DATE datatype:

cast(cast(ALL_DATES.DATEDATE as timestamp) as time) between time '08:00:00' and time '14:30:00'
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement