0

I have a column of timestamp ...

I'm going to use OBIEE and the user told me that need graphics per day, week and month...

Of the timestamp I'm extracting day, and month ... like this :

--day
select to_char(register_dt, 'DAY DD') as "Day"
from XX;

--by week

--by month
select to_char(register_dt, 'FMMONTH') as "Month"
from XX;

I found

select to_char( register_dt, 'WW' ) as "Week"
from XX;

but that only give me the number of the week like 36 etc, Can anybody help me to figure it out how to display a week range? like

I mean this is Sept 6, like

1 / Sept / 7

8 / Sept / 14

etc.. etc..

Please !! Thanks in advance

4

1 回答 1

2

您可以将 截断date到前一周的开始,然后对其进行操作。因此,例如,您可以运行类似

select trunc(sysdate, 'W') as first_of_week, 
       trunc( sysdate + 7, 'W' ) - 1 as last_of_week,
       to_char( trunc(sysdate, 'W'), 'DD-MON-YYYY' ) || ' to ' ||
         to_char( trunc( sysdate + 7, 'W' ) - 1, 'DD-MON-YYYY' ) as week_range
  from dual

得到一个字符串01-SEP-2013 to 07-SEP-2013作为week_range

于 2013-09-06T15:32:38.223 回答