Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Number of days since a certain date.

Re: Number of days since a certain date.

From: Christopher Beck <clbeck_at_us.oracle.com>
Date: Wed, 02 Sep 1998 20:05:16 GMT
Message-ID: <35ed8c2c.18138071@dcsun4.us.oracle.com>


On Wed, 02 Sep 1998 17:38:01 +0100, Iain Crawford <crawfori_at_ecid.cig.mot.com> wrote:

>Can anyone help me here??
>
>I need to know how many Thursdays there have been between a certain date
>and the current date. Can anyone give me any ideas on how this can be
>done in SQL*Plus.
>

This should work...

SQL> select sum(decode(to_char(sysdate-rownum,'D'),5,1,0)) THURS   2 from all_objects
  3 where rownum < sysdate - to_date('01-jan-98')   4 /

     THURS


        35

... as long as the all_objects table has at least as many rows as days between the two dates.

chris.

>Thanks
Received on Wed Sep 02 1998 - 15:05:16 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US