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

Home -> Community -> Usenet -> c.d.o.server -> Re: Extracting week of the year from Date field

Re: Extracting week of the year from Date field

From: Canberra <ctcanb_at_mail.zip.com.au>
Date: 31 Jul 1998 01:43:46 GMT
Message-ID: <01bdbc25$52d1e0a0$1c2a25cb@eagle>

rrachamallu_at_my-dejanews.com wrote in article <6pqqr1$7kv$1_at_nnrp1.dejanews.com>...
> Hi, I need to extract the week of the year/month from a date field. The
> calendar week starts on a sunday and ends on a saturday. For example July
1st
> ( wednesday) is in the first week of july and july 5th (sunday) is in the
> second week of july. So I cannot just use (day of the month / 7) to get
the
> week of the month. I am wondering if there is a built-in function in
oracle
> that can be used to do this. If you have a solution for this question,
please
> post the results.
>
> thanks.
> reddy

Have a look at the following examples:
They use the TO_CHAR function to convert the date (sysdate in the examples) to a string for the day of the week.

SQL> select to_char(sysdate,'DAY') from dual;

TO_CHAR(SYSDATE,'DAY')



FRIDAY SQL> select to_char(sysdate,'DY') from dual;

TO_CHAR(SYSDATE,'DY')



FRI Also you might want to look up TO_CHAR and date format elements in the Oracle doco.
Hope this helps.

-Richard Received on Thu Jul 30 1998 - 20:43:46 CDT

Original text of this message

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