I'm looking for a way to filter and display records using static values from a "Select list" page item. I have created a bar chart in APEX 5.0 using the following query:
select to_char(to_date(time_stamp,'YYYY-MM-DD-HH24:MI:SS'),'YYYY-MM-DD-HH24:MI:SS') as label, col2 as value from table1 where :P5_NEW_1 = col1 ;
The time_stamp column of table1
is of datatype varchar2
in my database and contains the date values in the format YYYY-MM-DD-HH24:MI:SS
e.g., values like below are stored in the time_stamp
column
2015-08-26-10:17:15
2015-08-26-13:17:15
2015-09-17-12:45:54
2015-09-17-14:12:32
2015-10-06-10:01:42
2015-10-06-11:01:28
2015-10-06-05:01:28
and so on...
I have added a "Select list" item named "interval" on my form that contains a pre-populated list of values like 1hr
, 6hrs
.
Now I want to modify the above query such that following should happen:
For the value of
1hr
selected from the drop down list, the query should check thetime_stamp
column and display the records for the last one hour(i.e., records which fall in range
to_char(sysdate - 1/24 ,'YYYY-MM-DD-HH24:MI:SS') to to_char(sysdate ,'YYYY-MM-DD-HH24:MI:SS'
)And for the value of
6hrs
selected from the drop-down list, the query should display records for the last 6 hours.(i.e., records which fall in range
to_char(sysdate - 6/24 ,'YYYY-MM-DD-HH24:MI:SS' to to_char(sysdate ,'YYYY-MM-DD-HH24:MI:SS'
) )
How do I modify my SQL query to add the above condition in my current SQL query, using static values from page item select list?