Click to See Complete Forum and Search --> : Return Days Between


skid
05-06-2003, 07:22 AM
Hi All,

I have to return the days of the week in between given two days. (i.e. given MONDAY and THURSDAY, it must return TUESDAY and WEDNESDAY). This assumes start of the week is SUNDAY. Can this be done thru SQL?

Thanks,
skid

skid
05-06-2003, 09:01 AM
I modified the query by balajiyes from the dates retreival thread. It works fine, but if you input the same v_from and v_to date, it returns all the dates.


select TO_CHAR(x.date_val,'DAY')
from
(
select TRUNC(sysdate,'YYYY')+ROWNUM -1 as date_val,
TO_CHAR(TRUNC(sysdate,'YYYY')+ROWNUM -1,'YYYYMM') as year_month,
TO_CHAR(TRUNC(sysdate,'YYYY')+ROWNUM -1,'DD') as day,
ROWNUM
FROM all_objects
WHERE TRUNC(sysdate,'YYYY')+ROWNUM -1 < ADD_MONTHS(TRUNC(sysdate,'YYYY'),12)
) x
where year_month = to_number(to_char(sysdate,'YYYYMM'))
and X.date_val BETWEEN next_day(trunc(sysdate,'MONTH'),'&from_day') AND next_day(next_day(trunc(sysdate,'MONTH'),'&from_day'),'&from_to')
/