Imran Hemani
Imran Hemani

Reputation: 629

Datetime between specific hour in Oracle

I have a column with the format of datetime: TRANDATE

In the query, there is a condition of startdate and enddate that shows all the transactions that have occurred between those dates of the column TRANDATE.

I want to add a condition of TIME in hour. So that it should return all the transactions that have occured between the starttime and endtime hour of TRANDATE.

The query would have 4 parameters: TRANDATE between startdate and enddate TRANDATE between starthour (number) and endhour (number)

How do I do the time (hour) part ?

Upvotes: 0

Views: 950

Answers (1)

mauro
mauro

Reputation: 5940

You can add a condition on hour between HOUR_START and HOUR_END this way:

... AND EXTRACT(HOUR FROM TRANDATE) BETWEEN HOUR_START AND HOUR_END ...

Upvotes: 3

Related Questions