Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Number of days since a certain date.
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
![]() |
![]() |