How to populate calendar table in Oracle?

前端 未结 3 1878
耶瑟儿~
耶瑟儿~ 2020-11-28 16:06

I want to maintain a calender table in Oracle DB which I want to populate with all the days of the year starting from 2011 to 2013 (it may be till any year). How can I do th

3条回答
  •  隐瞒了意图╮
    2020-11-28 16:28

    This is a simple and easy way to do it

    with calendar as (
            select :startdate + rownum - 1 as day
            from dual
            connect by rownum < :enddate - :startdate
        )
    select rownum as "S.No", to_date(day,'dd_mm_yyyy') as "Cal_Dt", to_char(day,'day') as "DayName"
    from calendar
    

提交回复
热议问题