DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Date return

  1. #1
    Join Date
    Jul 2000
    Posts
    4

    Question

    Hi Expert,

    I have problem to get "Date" element return.

    In my table A has 3 columns which is YEAR , no_of_week, and day. Data is looked like this :

    year no_of_week day
    ----- --------------- -----
    1999 46 5
    (YYYY) (WW) (D)

    I would like to combine this 3 columns and then return for me a actual date data which is "1999-NOV-16"

    I tried to do as following but i got error:

    SQL> select to_date('1999 46 5','YYYY WW D') from dual;
    ERROR at line 1:
    ORA-01820: format code cannot appear in date input format

    Please help me to solve the problem.

    Lygine*16/11/2K

  2. #2
    Join Date
    Sep 2000
    Posts
    19

    Post Ans

    The statement what you tried doesn't work because you can find a week on given date and not wise versa.

    So i think you need to wrote some thing like this.


    select decode(mod(to_number(YEAR),4),0,to_date('01-01-'||YEAR,'dd-mm-yyyy') + 1,to_date('01-01-'||YEAR,'dd-mm-yyyy') )+ WEEKS*7 +DAYS from dual


    BMV

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width