Oracle reverse date : inupt (number of the week, number of the date, year)

Hi experts,
*I have a date that has been stored in three separated columns in a oracle data base 10g:
-number of week: for example 30. (range 1-53)
-number of the day: for example 5. (range 1-7).
-year : for example 2010.
*i need to write a SQL code which concate and convert this three columns to one signle date in the format dd/mm/yyyy.
*This a concrete example:
-input:
number of the day: 2, number of the week :23, year 2010.
-ouput:
07/06/2010
Any idea will be welcome
Best regards.

Hi,
Here's one way :
alter session set nls_date_language = "english";
alter session set nls_territory = "america";
WITH date_parts AS (
select 2010 yr, 23 wk, 2 dy from dual union all
select 2010 yr, 39 wk, 2 dy from dual
SELECT next_day(to_date('0101'||yr,'DDMMYYYY')-7, 'SUN') - 1
       + 7*wk
       + dy
       AS dt
FROM date_parts;You might have to make some adjustments due to your nls settings.

Similar Messages

  • PS settlement in the previous year.

    Hi gurus,
    In our project we have a problem due to some reason some project had balance in 2009 and 2010  . So for that we are not able to close the project . Now what we have done according to client approval we have opened the CO period for 2009 and 2010 and revered and settled the value in previous periods. Can anyone tell me whether we are doing wrong? bcoz we have done for 1 project for testing.
    Next question is , Any adverse effect on current years COPA report because ultimately its flowing to COPA fron billing element WBS element. Actually reversal and settlement we are doing in the same 2009  and 2010 period only.
    Thanks in advance...
    Mrinal Dey

    Hi
    If the reversal and settlement happens in the same year, then there should be no impact
    br, Ajay M

  • What is the role of Lns process in oracle 10g data guard

    Hi ,
    plz help me out to find out the actual working of lns process in oracle 10g data guard
    when i use SYNC redo transport
    the output of v$managed_stanbdy is like that ..
    PROCESS PID STATUS CLIENT_PROCESS GR# SEQ#
    ARCH 9258 CLOSING ARCH 2 498
    ARCH 9260 CLOSING ARCH 1 499
    ARCH 9262 CLOSING ARCH 2 496
    ARCH 9264 CLOSING ARCH 1 497
    LGWR 9206 CLOSING LGWR 2 482
    its not display any info about lns,thats means lns is not working in SYNC redo transport mode ?
    but if i changed it to ASYNC then the out put of v$managed_stanbdy is like this ..
    PS PID STS CPS GR# SEQ#
    ARCH 9258 CLOSING ARCH 1 509
    ARCH 9260 CLOSING ARCH 2 510
    ARCH 9262 CLOSING ARCH 1 505
    ARCH 9264 CLOSING ARCH 2 508
    LGWR 9206 CLOSING LGWR 1 503
    LNS 10528 CLOSING LNS 2 510
    Now it display all the info about lns process...
    i read in oracle documentation that lns process send redo data from primary,( through network service ) to RFS on standby side.
    but first output means that lns is not working,if not then which process send redo from primary to RFS on standby ?
    i also read in some blog that lgwr use some extra buffer size from primary db SGA ,to write redo in that buffer ,ans lns read redo from that buffer and send it to RFS on stanby side,
    i m totally confused ..can u plz help me with correct logic behind this .
    thanx in advance.

    Hello,
    On the primary database when you run the v$managed_standby, it shows up the LNS process as this process sends redo info to the standby database and on the standby database the RFS process receives the redo information.
    So on the primary database when you query the v$managed_standby, it shows up LNS and on the standby database when you query the v$managed_standby it shows up RFS. Please let us know where you are running the query.
    Refer this http://datadisk.co.uk/html_docs/oracle_dg/architecture.htm
    969752     
    Handle:     969752
    Status Level:     Newbie
    Registered:     Nov 6, 2012
    Total Posts:     9
    Total Questions:     2 (2 unresolved)
    Name     Hemendra Singh
    Location     NoidaPlease consider closing your questions by providing appropriate points and marking it as answered. Please keep the forum clean !

  • How to determine the proper size for Oracle 8i Data Base Objects

    Hi,
    I'm working on an Oracle 8i Data base. I'd like to know how to determine the proper size for the Data Base objects such as tables, datafiles, tablespaces...
    Thanks.

    Start with the docs.
    http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a76956/schema.htm#949
    Best Regards
    Krystian Zieja / mob

  • How to control the default Reverse Date at VL09

    Hello,
    At VL09 (reverse goods movement) screen, the default Reverse Date is today.
    If users want to modify the Reverse Date,
    users have to select a line, click on define date button and input date into the local date field at pop-up screen.
    I want the default Reverse Date at VL09 screen to be the same as the Actual GI date of delivery.
    Please tell me how.
    Thank you.

    1. There is no standard BADI and userexit which can fulfill your requirement.
    2. You can try to do the modification in RVV50L09.
    Before
    "CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'"
    You can add  "Move XLIKPUKWA-wadat_ist to  XLIKPUKWA-STDAT. "

  • How to set the Reverse date to be the same as the Actual GI date by default

    Hello,
    On VL09 (reverse goods movement) screen, default reversal date is the system date.
    Users have to select the line, click on define date button and enter the correct cancellation date to the local date field on the pop-up.
    I want the reversal date on VL09 screen to be the same as the Actual GI date by default.
    Thank you.

    Hi,
    I checked the program.
    Check in routine FORM insert_data_for_reversal  --->  IF Condition (( xlikpukwa-wbstk EQ charc AND xlikpukwa-vbtyp CA vbtyp_lief ) OR  ( xlikpukwa-wbstk CA 'BC'  AND xlikpukwa-vbtyp CA vbtyp_liav ). ---> 2 performs are there one with '01' and other with '02' as actual parameters.
    In your case '01' is passing to the routine. if you try to pass '02' u can achive your requirement.
    For testing in debug mode pass FIELDS-FIELD_ATTR = '02' for field name DATLO. then you can see the output.
    Try to handle this problem using Enhancement Operations.
    Hope this helps you.
    Thanks
    Raghavendra

  • Keep the Oracle Spatial data in memory

    I can keep any database tables in memory (for fast access) using Oracle Coherence (the In Memory Data Grid).
    Now I want to store Oracle Spatial data in memory, is it possible?

    I think it is possible. The difference is it is not easy to recreate some Spatial-related functions and procedures in caches. But you can invoke them from the in-memory applications using Oracle Spatial Java API.

  • Who can tell me  the ' Oracle Application Data Exchange ' download url ?

    Who can tell me the ' Oracle Application Data Exchange ' download url ?
    thanks
    Yiming Gao
    [email protected]

    Can you refer the Note:68795.1 ?
    Regards

  • Help - Reverse Date Numbering Confusion

    I'm new to the Aperture forum but not really new to Aperture I've been using it on and off for about 2 years now and mostly have the hang of it
    Recently I started to shoot a lot more and since reshaped how I import name and catalog files
    I havent really noticed any issues till today when I imported some images after formatting and I'm getting a little confused since my settings for aperture were not updated after the format so maybe someone can shed some light or at least point me in the right direction..
    Here is my issue:
    When I shoot and import I want to be using a reverse date file name for example 20110101_Charlie_(image number from camera)
    Ideally the number would just be that of whatever sequence it was shot from the camera as I dont want every shoot to start with 20110101_Charlie_01 etc.. Id prefer to see 20110101_Charlie_555
    I shot someone last week and when I imported them all the numbers were up in the 700 range which was fine It wasnt until I imported a new shoot that I did about 3 weeks before that where I saw the file naming to be down near the 50 mark.. I was really confused.
    I went back through some old images I shot a while ago where I was using reverse date and updated them thinking that they would use the camera's numbering system but they all jumped up into the 600's as well and they werent even shot with this camera. It's all getting really confusing
    To top it off, when I shoot on the back of my lcd I see the file numbering to be in the 7000's so I have NO idea why Aperture is naming them anything less.
    Can someone explain correctly how to either import them with the settings that I want or how to batch edit them (I know how to batch edit and my preference would be importing them with the settings would be easier)
    I'm importing them using a custom name and counter and I was simply changing the job names and dates upon import. Is there an easier way to do things?

    Quietcity wrote:
    1st question: Is there a way to reverse the numbering of pages in a Pages document? For instance, in a 20 page document, is there a way to make the last page be numbered as "page 1" and the first page be numbered "page 20"?
    NO with standard tools.
    2nd question: is there any way to "flip" the page order of a Pages document? By that, I mean making the last page the actual first page and vice versa, along with a corresponding re-ordering of all the pages therein.
    NO
    Side rant: The forum search function is pretty crude. My various searches for "page number" or "page numbering" kept giving results as though I was actually searching for "Pages" and "Numbers." And no matter how what search terms I used, with or without single or double quotes, I kept getting the exact same citations.
    I apologize but I didn't get the same behavior.
    If I search for print number without quotes, I get 10 pages of returned links.
    If I search for "print number" with the double quote, I get onlt 5 pages.
    This proves that the filter does its duty.
    Yvan KOENIG (VALLAURIS, France) samedi 19 septembre 2009 20:53:48

  • How to populate the data or details of only the present year and the previous year with respect to the given RATNG?

    Hi All,
    I have created a form with 5 blocks (namely ENQACMHDR, ENQACMDTL, ENQACEHDR, ENQACEDTL, ENQACSPEC), where i have 8 push buttons (namely ENTER_QUERY, EXEC_QUERY, CLEAR, FIRST, NEXT, PREVIOUS, LAST & EXIT).
    This form is created just for viewing purpose only. So after I execute, all the blocks have been blocked against insert & update.
    I query on 2 fields that is 'ENQNO' and 'RATNG' (Both the fields belong to the block ENQACMDTL).
    When I click on 'EXEC_QUERY' directly, all the data of all the years populates.
    But the user wanted the data to be populated from only the present year and the previous year.
    So , on 'WHERE Clause' of the property_palette of 'ENQACMDTL' block , I put in the following condition:
    SUBSTR(ENQACMDTL.ENQNO, 1,4)=TO_CHAR( ADD_MONTHS(SYSDATE,-12) , 'YYYY') OR SUBSTR(ENQACMDTL.ENQNO, 1,4)=TO_CHAR(SYSDATE, 'YYYY')
    PROPERTY PALETTE (ENQACMDTL block)
    WHERE Clause
    SUBSTR(ENQACMDTL.ENQNO, 1,4)=TO_CHAR( ADD_MONTHS(SYSDATE,-12) , 'YYYY') OR SUBSTR(ENQACMDTL.ENQNO, 1,4)=TO_CHAR(SYSDATE, 'YYYY')
    Now the data of only the present year and the previous year is being populated. Its ok with the field of 'ENQNO'.
    The problem is when i query on field 'RATNG' . 'RATNG' is a Text_item with Number of Items displayed=5. (5 rows)
    The following are 2 columns of a Table (Name=ENQACMDTL) in Database.
    ENQNO
    RATNG
    2013900054
    500KC2
    2013900047
    800KC4
    2013520018
    750KC6
    2012900037
    1000KC2
    2012520109
    500KC2
    2012140019
    750KC6
    2011540036
    500KC2
    2011100030
    1000KC2
    2006100007
    90KD8
    2006750014
    750KC6
    2006900072
    500KC2
    The first 4 numbers of 'ENQNO' denotes the year. There are more than a lakhs of records.
    So when i query on the field 'RATNG',
    Example:For RATNG=500KC2;
    I click on ENTER_QUERY, On the field of 'RATNG' , i put in the value 500KC2 and click on  EXEC_QUERY; Details with respect to 500KC2 is displayed as well as all the other unwanted RATNG like 750KC6, 1000KC2 (which belongs to the ENQNO of the present year and the previous year) also gets displayed.
    I want details of only RATNG (500KC2) to be displayed, but only of the present year and the previous year, that is 2013900054, 2012520109 (ENQNO).
    Other than 500KC2 RATNG, no other RATNG must be displayed.
    The RATNG=500KC2 is also present for ENQNO=2011540036 , 2006900072. But I dont want these to be displayed.
    I want only the data or details of the present year and the previous year to be displayed or populated with respect to the given RATNG.
    Can You Help me or tell me what do i do for this?
    Hope I'm clear with my question!!
    If my question is not clear, let me know plz.
    Thank You.
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    Oracle forms 6i.

    On key-exeqry you have to program.  Delete all other trigger codings for checking your condition.
    It dint work on key-exeqry.
    I tried key-exeqry on form trigger, block (enqacmdtl) and also on field(:enqacmdtl.enqno) , but none of them worked.
    It did not display the message.
    I have a 'PUSH-BUTTON:EXEC_QUERY.
    For EXEC_QUERY, Trigger : WHEN_BUTTON_PRESSED;
    I added the following code:
    if to_number(substr(:enqacmdtl.enqno,1,4))<to_number(to_char(add_months(sysdate,-12),'YYYY')) then
         message('The Rating is not present for the present year and the previous year');message(' ',no_acknowledge);
         raise form_trigger_failure;
    else
         execute_query;
    end if;
    It is working fine and the message is being displayed.
    But again I have a new problem and that is;
    On the field :enqacmdtl.enqno, when i enter the '2013%' and press 'EXEC_QUERY', it works fine.
    but when i enter '2006%' and press 'EXEC_QUERY', it shows the following error
    FRM-50016: Legal characters are 0-9 - +E. It does not display the message also.
    but when i enter the complete number, '2006580002', then it works fine , that is it displays the message (The Rating is not present for the present year and the previous year).
    The problem is because of '%', only when i put in the restricted data (which does not satisfy where condition).
    How do i solve this?
    Thank You Priyasagi.

  • ORACLE Parameter Data Types

    Hi,
    We are using for all Oracle number columns the Oracle parameter type OracleType.Number.
    Now we have seen that we can also use the type OracleTyp.Int32.
    Is it better or faster to use this type for columns
    which can use this type.
    Have anybody experience with using Oracle data types ??
    Kind Regards
    Martin

    It really depends on what kind of data you're inserting or updating. If you've data that can be accomodated in an integer, you should use OracleDbType.Int32 over OracleDbType.Decimal. You get much better performance by using Byte, Int16, Int32, Single, Double over Decimal but these types can not hold the same precision and scale as Decimal type can.

  • [urgent] oracle-xe data failure, udump file generation resulted in fulldisk

    Hi all - We've been running oracle-xe for some time, for the past week the trace files generated in udump peeked out and resulted in a full disk. After freeing up some diskspace and then rebooting the data written to the oradata /*.dbf seems to be lost for the last week. Our backups seems to be corrupt as well as this happened a few days ago.
    Our database is relatively small ~6-7GB in datafiles /*.dbf, the trace files reached 129GB.
    We are considering different disaster recovery alternatives offered by Oracle but would like to know if there is anything we can do? Would it be useful for a support technician to get access to the udump files, do they contain any useful information that might be recoverable?
    Thanks in advance,
    Mikael
    version: oracle-xe 10.2.0.1.0

    A few lines:
    db_recovery_file_dest_size of 10240 MB is 0.98% used. This is a ...
    Heap size 2208K exceeds notification threshold (2048K) ...
    It doesn't say that much but I will keep monitoring it. Check details on the storage:
    Space Allocated: 1.092 MB
    Available: 4.028 MB
    Physical Limit: 5.120 MB
    Percent Used: 21%
    Could this information be wrong?
    Here's a ls -la from oradata:
    -rw-r----- 1 oracle dba 7061504 Apr 10 16:54 control.dbf
    -rw-r----- 1 oracle dba 597696512 Apr 10 16:46 sysaux.dbf
    -rw-r----- 1 oracle dba 408952832 Apr 10 16:51 system.dbf
    -rw-r----- 1 oracle dba 308289536 Apr 10 16:47 temp.dbf
    -rw-r----- 1 oracle dba 183508992 Apr 10 16:46 undo.dbf
    -rw-r----- 1 oracle dba 104865792 Apr 10 15:46 users.dbf
    So, what if we run the database for 2 weeks and we fill up the remaining limit 21->100% does it mean that everything will be gone since the last start if we shut it down and perform a backup?
    It would feel a lot better if we could take the storage issue out of the equation,
    Thanks again, appreciate it!
    Mikael

  • Reverse Of any number,Fibonacci sequence

    hi all,
    Can i find the reverse of any number and Fibonacci sequence in a SELECT query
    without using pl/sql and reverse function.
    please reply...

    Hi,
    extreme wrote:
    ... can you give me example for both 10g and 11gR2 recursive sub-queriesRecursive sub-queries were introduced in Oaracle 11.2; there are no recursive sub-queries in earlier versions.
    Here's one way of getting the reverse of a NUMBER in Oracle 10 (and up):
    WITH     got_txt     AS
         SELECT     TO_CHAR (12345, 'TM')     AS txt
         FROM     dual
    ,     exploded_txt     AS
         SELECT     LEVEL               AS pos
         ,     SUBSTR (txt, LEVEL, 1)     AS a_char
         FROM     got_txt
         CONNECT BY     LEVEL <= LENGTH (txt)
    SELECT  TO_NUMBER ( REPLACE ( XMLAGG ( XMLELEMENT ( e
                                              , a_char
                                          ).EXTRACT ('//text()')
                                 ORDER BY  pos     DESC
                )     AS reverse_num
    FROM    exploded_txt
    ;As written, this only does one number per query. It can be adapted to do several numbers at the same time, but it's somewhat messier.
    Starting in 11.2, you cn also use a recursive sub-query, as show below.
    This method can easily handle multiple numebrs in the same query. You'll probably get them from one of your existing tables, not hard-coded in a sub-query, like sample_data, below:
    WITH     sample_data AS
         SELECT  12345     AS n     FROM dual     UNION ALL
         SELECT     30.2             FROM dual     UNION ALL
         SELECT     0          FROM dual
    ,     got_txt (n, step, txt, reverse_txt)     AS
         SELECT     n
         ,     1                    AS step
         ,     TO_CHAR (n, 'TM')          AS txt
         ,     SUBSTR ( TO_CHAR (n, 'TM')
                     , 1
                     , 1
                     )               AS reverse_txt
         FROM    sample_data
        UNION ALL
         SELECT     n
         ,     step + 1          AS step
         ,     txt
         ,     SUBSTR ( txt
                     , step + 1
                     , 1
                     ) || reverse_txt     AS reverse_txt
         FROM    got_txt
         WHERE     step     < LENGTH (txt)
    SELECT     n
    ,     TO_NUMBER (reverse_txt)     AS reverse_n
    FROM     got_txt
    WHERE     step     = LENGTH (txt)
    ;A somewhat simpler problem is how to reverse a given string.
    As you can see, boith of the approaches above start by converting the given number to a string, and end by converting it back to a NUMBER, to meet your requirements.
    Neither version (as posted) handles negative numbers properly. Both can be adapted to do so.

  • Fail to convert to internal representation: oracle.sql.DATE

    I'm using the oracle 8.1.7 jdbc driver against oracle 8.1.7 running on NT, and I get the exception message below when I attempt to insert an jpub object structure into a prepared statement.
    All date objects have been constructed from a timestamp object, using the oracle.sql.DATE Timestamp constructor. So I'm surprised to get this error given the timestamp object was successfully constructed.
    I've tried session date formats of 'yyyy-mm-dd hh24:mi:ss' and 'mm/dd/yyyy hh24:mi:ss', with no success.
    I can call stringValue on oracle.sql.DATE and it returns a valid date.
    Can someone confirm that they have been able to use the oracle.sql.DATE class to insert a date correctly into the database? Its seems a silly question to ask but you have to start somewhere!
    Exception : Fail to convert to internal representation: oracle.sql.DATE@3c144e8a
    Stack trace : java.sql.SQLException: Fail to convert to internal representation: oracle.sql.DATE@3c144e8a
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:829)
    at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTypeADT.java:261)
    at oracle.sql.StructDescriptor.toOracleArray(StructDescriptor.java:385)
    at oracle.sql.StructDescriptor.toArray(StructDescriptor.java:560)
    at oracle.sql.STRUCT.<init>(STRUCT.java:95)
    at oracle.jpub.runtime.MutableStruct.toDatum(MutableStruct.java:65)
    null

    The JPub/JDBC runtime is converting your Java object into Oracle-specific representation (all data is put in oracle.sql.XXXX format). The top level object is an oracle.sql.STRUCT, the attributes of which are represented as an array of oracle.sql.Datum objects - in your case an oracle.sql.NUMBER and an oracle.sql.DATE. However, the error does occur in the StructDescriptor which describes the SQL type and the shape of the object. Is the error dependent on the data values? Might null values not be dealt with, correctly?
    One thing to try to do is create such an oracle.sql.STRUCT object from scratch with the same attribute values and insert/manipulate that using SQL.
    I have not dealt with TAR's. If you send me a self-contained test case, I'll check it against the current development version of JDBC. (At least you'll know if the next JDBC release fixes this issue :-) I might also file a bug.

  • How to change the year in a range of column dates to the new year?

    How to change the year in a range of column dates to the new year?

    Depends on the pattern of the dates. The last procedure will work for any pattern, or no pattern at all.
    For examples.the dates are assumed to be in column A, starting at A2
    Sequential dates?
    Enter first updated date in the first cell.
    Enter =A2+1 in cell A3. Copy the cell.
    Select A3 to the end of the list. Paste.
    With the cells still selected, Copy, then go Edit > Paste Values.
    Evenly spaced dates?
    Same procedure as above, but replace +1 in the formula with + and the number of days between dates in the list.
    Randomly spaced dates?
    Select cell B2. Press option-left arrow to insert a (temporary) column to the left of column B.
    Click on the empty cell B2 in the new column. Enter the formula below:
    =DATE(YEAR(A)+1,MONTH(A),DAY(A))
    Copy the cell, then select B2 - Bn where n is the last ow containing a date to be converted. Paste,
    With the cells still selected, Copy.
    Click on A2, then go Edit > Paste values.
    Click on the column B reference tab to select all of column B.
    Hover the mouse over the right end of the reference tab, and click the black triangle when it appears.
    Choose Delete Column from the menu that appears.
    Regards,
    Barry

Maybe you are looking for