Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How Do I Get a list of Days for a Given Month?
You could create a simple procedure as such...
Create or replace procedure that_month ( in_date in varchar2) as
begin_date date;
end_date date;
days_in_month integer;
begin
end_date := last_day(in_date);
begin_date := last_day(add_months(in_date, -1)) + 1;
days_in_month := end_date - begin_date;
for i in 0 .. days_in_month loop dbms_output.put_line(begin_date + i); --htp.p(begin_date + i); end loop;
end;
You're doing web applications so your output would use 'htp.p' which is commented instead of 'dbms_output.put_line'.
On Fri, 23 Oct 1998 11:47:46 -0400, "Shonte' N. Poe" <spoe2_at_isp.ford.com> wrote:
>I am trying to get a list of days for a month, given a specific date.
>
>For example, if I am given the date of '04-OCT-97',
>I want to get a list as follows:
>
>01-OCT-97
>02-OCT-97
>03-OCT-97
>04-OCT-97
>05-OCT-97
>06-OCT-97
>07-OCT-97
>08-OCT-97
>09-OCT-97
>10-OCT-97
>11-OCT-97
>12-OCT-97
>13-OCT-97
>14-OCT-97
>15-OCT-97
>16-OCT-97
>17-OCT-97
>18-OCT-97
>19-OCT-97
>20-OCT-97
>21-OCT-97
>22-OCT-97
>23-OCT-97
>24-OCT-97
>25-OCT-97
>26-OCT-97
>27-OCT-97
>28-OCT-97
>29-OCT-97
>30-OCT-97
>31-OCT-97
>
>
>The closest I have come is obtaining the start and end dates
>for the month:
>
>select
>ADD_MONTHS(LAST_DAY('04-OCT-97'),-1)+1 "First of Month"
>from dual
>
>union
>
>select
>LAST_DAY('04-OCT-97') "Last of Month"
>from dual
>;
>
>
>Please Help...
>Thanks...
Good Luck! Brian_RestonVA
Oracle GEHS
The opinions expressed are mine and do not
necessarily reflect those of Oracle Corporation.
Received on Sat Oct 24 1998 - 12:19:14 CDT
![]() |
![]() |