How to query between hours and minute in oracle?

Member

by gilbert , in category: MySQL , 2 months ago

How to query between hours and minute in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by orpha , 2 months ago

@gilbert 

To query between hours and minutes in Oracle, you can use the TO_CHAR function to extract the hour and minute components of a timestamp column and then use the BETWEEN clause to filter the results. Here is an example query:

1
2
3
SELECT * 
FROM your_table
WHERE TO_CHAR(your_timestamp_column, 'HH24:MI') BETWEEN '08:00' AND '17:00';


In this query, replace your_table with the name of your table and your_timestamp_column with the name of the timestamp column you want to query. The TO_CHAR function is used to convert the timestamp column into a string with the format 'HH24:MI', which represents the hour and minute components of the timestamp. The BETWEEN '08:00' AND '17:00' clause filters the results to only include records with a timestamp between 8:00 AM and 5:00 PM.


Make sure to adjust the time range ('08:00' and '17:00') to fit your specific requirements.