Re: Oracle Dates
From: ddf <oratune_at_msn.com>
Date: Tue, 5 Jan 2010 19:30:51 -0800 (PST)
Message-ID: <ec3fdfe4-4cf3-4e4c-9b24-7ad0b4b29671_at_s3g2000yqs.googlegroups.com>
On Jan 5, 9:09 pm, The Magnet <a..._at_unsu.com> wrote:
> On Jan 5, 6:48 pm, yf..._at_vtn1.victoria.tc.ca (Malcolm Dew-Jones)
> wrote:
>
> > The Magnet (a..._at_unsu.com) wrote:
>
> > : Is there a way for me to figure out how many days in 3 months? For
>
> > I can't test this, but my first thought is to try something like this
> > example for counting the days in Jan Feb and March of this year.
>
> > number count_days_in_3_months :=
> > to_date('1-APR-2010','DD-MON-YYYY')
> > - to_date('1-JAN-2010','DD-MON-YYYY')
>
> Yes, but I do not actually know the months. All I know is that the
> offset starts with "v_date", and I want to count the days, 3 months
> forward. Hoping not to have to code a bunch of stuff, must be some
> function or something.
9 end;
10 /
92
Date: Tue, 5 Jan 2010 19:30:51 -0800 (PST)
Message-ID: <ec3fdfe4-4cf3-4e4c-9b24-7ad0b4b29671_at_s3g2000yqs.googlegroups.com>
On Jan 5, 9:09 pm, The Magnet <a..._at_unsu.com> wrote:
> On Jan 5, 6:48 pm, yf..._at_vtn1.victoria.tc.ca (Malcolm Dew-Jones)
> wrote:
>
> > The Magnet (a..._at_unsu.com) wrote:
>
> > : Is there a way for me to figure out how many days in 3 months? For
>
> > I can't test this, but my first thought is to try something like this
> > example for counting the days in Jan Feb and March of this year.
>
> > number count_days_in_3_months :=
> > to_date('1-APR-2010','DD-MON-YYYY')
> > - to_date('1-JAN-2010','DD-MON-YYYY')
>
> Yes, but I do not actually know the months. All I know is that the
> offset starts with "v_date", and I want to count the days, 3 months
> forward. Hoping not to have to code a bunch of stuff, must be some
> function or something.
add_months(v_date, 3) - v_date
returns the number of days:
SQL> select add_months(sysdate, 3) - sysdate 2 from dual;
ADD_MONTHS(SYSDATE,3)-SYSDATE
90 SQL> declare 2 v_date date:= to_date('06/01/2010','MM/DD/RRRR'); 3 v_days number; 4 begin 5 select add_months(v_date, 3) - v_date 6 into v_days 7 from dual; 8 dbms_output.put_line(v_days);
9 end;
10 /
92
PL/SQL procedure successfully completed.
SQL> David Fitzjarrell Received on Tue Jan 05 2010 - 21:30:51 CST