DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Return Days Between

  1. #1
    Join Date
    Apr 2002
    Location
    Philippines
    Posts
    77

    Return Days Between

    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

  2. #2
    Join Date
    Apr 2002
    Location
    Philippines
    Posts
    77
    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.

    Code:
    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')
    /

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width