Parsing VARCHAR to DATE where the VARCHAR column has multiple format

Hello,
I'm a little stumped here so I figured I'd try posting here.
I have an application where I can not alter the code. This application has a form with a calender conrol on it that allows the user to select a date. This form is internationalized so date formats vary based on the country the user is coming form (mm/dd/yyyy, dd-Mon-yyyy, dd.mm.yyyy, etc). The application saved the string of the date as the calender control returns to the form, it does not save the value as a date value.
I need to preform a query that can do some cacluations off of this date. When there is only one date format returned in the query, there is no problem
CASE WHEN TO_DATE(d3.data,'Mon/dd/yyyy')-NVL(trunc(i3.end_date),trunc(SYSDATE)) < 0 THEN calc_business_days(TO_DATE(d3.data,'Mon/dd/yyyy'),NVL(trunc(i3.end_date),trunc(SYSDATE)))
WHEN TO_DATE(d3.data,'Mon/dd/yyyy')-NVL(trunc(i3.end_date),trunc(SYSDATE)) > 0 THEN 0-(calc_business_days( NVL(trunc(i3.end_date),trunc(SYSDATE)) ,TO_DATE(d3.data,'Mon/dd/yyyy')))
ELSE 0 END
However, this errors when there are multiple formats in the varchar column for the same query. Can anyone provide any guidance on how to handle this? I am using Oracle 10g.
Thanks

The simplest option is generally to create a new function that does the conversion and sets up a hierarchy of date formats. Obviously, there may be some data loss here-- '01/02/03' is a valid string in the format mm/dd/yy, dd/mm/yy, and yy/mm/dd but it means different things in each.
Something like
CREATE OR REPLACE FUNCTION my_to_date( p_in_string VARCHAR2 )
  RETURN date
IS
BEGIN
  RETURN to_date( p_in_string, 'MM/DD/YYYY' );
EXCEPTION
  WHEN others THEN
    BEGIN
      RETURN to_date( p_in_string, 'DD-MON-YYYY' );
    EXCEPTION
      WHEN others THEN
        BEGIN
          RETURN to_date( p_in_string, 'DD.MM.YYYY' );
        EXCEPTION
          WHEN others THEN
            RETURN NULL;
        END;
    END;
END;
/Justin

Similar Messages

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • How to insert data into the BLOB column

    Hi All,
    Can anyone help me to insert data into the BLOB data type column?
    The table structure is
    CREATE TABLE XXATFL_DM_FORCAST_STG
    TASK_ID NUMBER,
    USER_ID NUMBER,
    CREATED_BY NUMBER(15),
    CREATION_DATE DATE,
    LAST_UPDATED_BY NUMBER(15),
    LAST_UPDATE_DATE DATE,
    LAST_UPDATE_LOGIN NUMBER(15),
    RECORD_STATUS VARCHAR2(1 BYTE),
    ERROR_MESSAGE VARCHAR2(4000 BYTE),
    DATA_FILE BLOB
    I want to insert data in the DATA_FILE column. and this insert statement will in inside a procedure.
    Please help me as soon as possible as this is very urgent for me
    Thanks & Regards,
    Chandan

    i tried like this
    sql> insert into tbl values(1, utl_raw.cast_to_raw('D:\pictures\pic2.bmp'));
    1 record created.
    sql>select * from tbl;
    sp2-0678:Column or attribute type can not be displayed by SQL*PLUS
    sql>
    is this saving only path or bmp file on that path?
    if it is saving bmp file, in which format and how can we retrive it?
    Edited by: user8967883 on Mar 31, 2010 12:57 PM

  • Read data in the first column selected in a Multicolumn listbox

    When a row is selected in a multicolumn listbox (1 item), how do I go about reading the data in the first column?
    Solved!
    Go to Solution.

    The multicolumn listbox itself is numeric array data type. If you have allowed selection of only 1 item and selection mode of select entire row, it returns the row number. Use the "Item Names" property node to return a 2d array of strings of the items in your box. Index it by the row from the value of the listbox and column 0. See attached code.
    Charles Chickering
    Architecture is art with rules.
    ...and the rules are more like guidelines
    Attachments:
    MultiColumnListbox.vi ‏5 KB

  • Is it possible to hide the data in a formatted cell until the data from the relevant cells has been entered?

    I have a balance sheet and I'd like to be able to hide the data in the balance column until the 'In' or 'Out' for that day has been entered
    Any ideas greatfully received!

    Hi Quinn,
    I am surprized that apple makes me go to a custom rule to chose a white font color.
    To get
    Or use the colour window: View > Show Colors (shift command c).
    Click on a colour to apply it to text of selected cells.
    Drag a colour to the selected cells to apply it as the Fill:
    Some of the features that we thought were lost are just Hidden in Numbers 3! (I can't wait for a decent User Guide).
    Regards
    Ian.

  • I'm moving an internal hard drive from an old computer to a new computer.  How do I transfer the catalog data to my new computer so the Organizer of Photoshop Elements 6 will find the data on the hard that has been moved to the new computer?

    I'm moving an internal hard drive from an old computer to a new computer.  (My new compute runs Windows 8.1) How do I transfer the catalog data to my new computer so the Organizer of Photoshop Elements 6 will find the data on the hard that has been moved to the new computer?  Is this possible or do I have to use the procedure of copying the catalog along with the photos to a back up hard drive and then restore them on the new computer?

    The 'normal' procedure is to do a PSE organizer backup (not a copy or a backup from external tools) to an external drive, then a restore to the new location.
    The advantage is that you have a backup of both catalog and media files and you don't have all disconnected files, which would happen with external backup tools. Also, if you restore with a more recent elements version, the catalog will be automatically updated to the new format.
    The drawback in your situation is that you'll have either to overwrite all your files or restore to a custom location, creating a duplicate photo library (which supposes you have enough free space).
    It would be possible to simply use the organizer in the old PC to move the catalog to a new 'custom' folder just under your C: root drive. The catalog would be accessible once the drive will be installed in the new PC. Then you would have all files 'disconnected' due to the fact that all your media files are now on a drive with a different letter. Reconnecting a whole library is a hard job with PSE6, less so with PSE11/PSE12.
    If the idea of fiddling with the sqlite database with external sqlite manager tools is ok for you, I can describe the process more in detail. You only copy your catalog folder (as suggested above) to another location. Instead of trying the 'reconnection' way, you install the sqlite utility on the new computer. When the old drive is installed in the new computer, you simply edit a given record in the catalog database, catalog.psedb, and start the organizer with your copied catalog by simply double clicking the 'catalog.psedb' file.
    Even if the last solution is much, much quicker, I would still create a new PSE backup : you have never too much safety .

  • HT1657 I cannot play my rented movie because itunes cannot locate where the original file, has anyone face this problem before? Where can I find the location of the downloaded movie?

    I cannot play my rented movie because itunes cannot locate where the original file, has anyone face this problem before? Where can I find the location of the downloaded movie?

    What did you use to download it with? iPad? iPhone? Computer?
    If it's an iPad/iPhone, play it using the videos app.
    If on the computer, look on the left side of iTunes in the library under movies.

  • Hi my airport router ( ateast i think this is where the problem originates) has been turning off intermittenly for the past week, when it does this NO devices recieve internet connection, mac, pc,iphone, ipad, wireless or hardwired directly to the router

    Hi my airport router ( ateast i think this is where the problem originates) has been turning off intermittenly for the past week, when it does this NO devices recieve internet connection, mac, pc,iphone, ipad, wireless or hardwired directly to the router. However they all show to be connected with their corresponding bars and the ip's are all fine. Earlier today it started flucuating on and off about every 5 min making work impossible and now it seems to be completely broken (im currently on my iphone connected though its own internet) Does anyone know how or ehy this happened and how i can fix this? And to know if this originates from the router or something else entirely. Thank you!

    Hi - some clarifications would help narrow down some symptoms - just what has been turning off? - has the light been solid green but the modem isn't providing wi-fi? - or is the light flashing yellow with no internet? - which can mean several things - does the light go out completey? - so if you can report on exactly what is happenening and when, maybe someone can help you - we also need to know if there any error messages along the way -  we also need the types of devices involved and how they are attached - kind of like a nework map  - the more info that you provide, the more answers you will get.
    Regards,
    Charlie    -

  • TS2570 Does this also include the scenario where the grey screen has a picture of 2 disk drives?

    Does this also include the scenario where the grey screen has a picture of 2 disk drives?
    One is labelled Macintosh HD and the other is Recovery HD.
    The computer doesn't always start up like this but it has a few times now.

    This screen shows up if your holding the option/alt key down or perhaps if it's stuck or damaged.
    It's called Startup Manager and shows your bootable options.
    Another possible cause is your PRAM is not remmebering the System Preferences > Startup Disk selection.
    Do a #2 Reset PRAM and head to System Preferences > Startup Disk and set it and hopefully that should resolve the issue.
    ..Step by Step to fix your Mac

  • How to clear the node which has multiple attributes

    Hello ,
               how to clear the node which has multiple attributes.
    I've tried this using the method SET_STATIC_ATTRIBUTES_NULL but it's not working.
    Thanks,
    Sandhya.

    Hello,
    I suggest you to create an internal table or structure clear it and the bind it to the context node.
    Another possibility is to try to invalidate the node (method INVALIDATE of interface IF_WD_CONTEXT_NODE).
    Regards.

  • Getting varchar  declared data from the database

    Hi every one,
    I am getting the data from Database Sql Server but I encountered a problem while retrieving the varchar datatype from the database,I read that it can be done by getString which I tried but It am not getting the data from the database,in the database it is declared as
    (varchar(100),Null),I tried but could't get that one
    any body please help me out,
    thanking you,
    with regards

    java.sql.SQLException: [Microsoft][SQLServer 2000
    Driver for JDBC]ResultSet can not re-read row data for
    column 6.
    This I am getting the exception and code is
    the error message says it all. You are obviously calling getString(6) twice, which is not allowed. You have to store the value of that column into a string when you read it the first time.
    Thomas

  • Best way to derive a "week ending" date using the Derived Column Transformations

    Hi, I have an interesting challenge. I am working on creating a BI DB that contains timesheet data. The data contains a column representing the date "worked"  ([Date]. Nearly all output reporting is based on a timesheeting week that end on
    a Wednesday. My thinking has been to create a derived column "WE" (week ending) that represents the entries of the preceding 6 days.
    (Originally I entertained deriving this value view SQL view - however we are talking about a DB that is is a substantial DB (excess of 100M timesheet bookings) and an index on the WE field is warranted) so decided a derived WE column was best approach.
    The Date field is represented from a SAP format (German long dated format) - however I cannot use the convert option ;( in the TE.
    The Date field is derived via: (DT_DATE)(SUBSTRING([Date      ],7,4) + "-" + SUBSTRING([Date      ],4,2) + "-" + SUBSTRING([Date      ],1,2))
    I would welcome some recommendation on how to best derive a WE column. (The DT_DATE format is not susceptible to a /7, mod7 operation).
    Thanks in advance,
    /L

    Try this solution :
    http://stackoverflow.com/questions/1803987/how-do-i-exclude-weekend-days-in-a-sql-server-query

  • Inserting value in the single column table where the only column is a identity column

    Hi,
    Following is my table definition:
    create table test1 (col1 int primary key identity(1,1))
    Now here, the only column col1 in the table is an identity column. Now I want to add explicit values to this column
    without SET Identity_Insert test1 On.
    How?

    You have a fundamental misconception. IDENTITY is not a column; it is a table property and it is totally non-relational. This is a left-over from UNIX file systems, which were built on magnetic tape files. It is a sequential data
    model which counts the insertion attempts to get a physical record number. By definition IDENTITY cannot be a valid key; it is not a valid data type (all data types in SQL are NULL-able); keys are a subset of columns in a table. 
    Have you ever read a single book on RDBMS? You can start with MANGA GUIDE TO DATABASE, it is the clearest intro book I know. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to remove the duplicate Columns in Multiple Rows?

    Hi,
    I want to remove the duplicate columns in a Multiple Rows.
    For example:
    Now i'm getting the output like this
    S_NO Order_number Assy_item Assy_Desp Item_Number
    1     S3123 12345 TEST     *1245*
    2     S3123 12345 TEST     *1256*
    3     S3123 12345 TEST     *1289*
    4     S3123 12345 TEST     *1223*
    5     S4123 42345 SAMPLE *4568*
    6     S4123 42345 SAMPLE *5656*
    7     S4123 42345 SAMPLE *4558*
    the Original output should be like this
    S_NO Order_number Assy_item Assy_Desp Item_Number
    1     S3123 12345 TEST     *1245*
    2                         *1256*
    3                         *1289*
    4                         *1223*
    5     S4123 42345 SAMPLE *4568*
    6                         *5656*
    7                         *4558*
    note: Alignment Problem all the Bold Numbers are Item Number(Last Column)*
    i'm using XML and RTF template.
    RTF Template is a Basic Table like Structure
    i pasted the XML code below
    <?xml version="1.0" encoding="UTF-8"?>
    <dataTemplate name="items" version="1.0">
    <parameters>
    <parameter name="P_DATE" dataType="date"/>
    <parameter name="P_DEPT_NO" dataType="varchar2"/>
    </parameters>
    <dataQuery>
    <sqlStatement name="ROW1">
    <![CDATA[
    SELECT
    SUBSTR(IMGR.ORDER_NUMBER,3,2) MACHINE_NO
    ,IMGR.ORDER_NUMBER
    ,IMGR.ASSY_ITEM_NUMBER
    ,IMGR.ASSEMBLY_DESCRIPTION
    ,IMGR.ITEM_NUMBER
    ,IMGR.ITEM_DESCRIPTION
    ,SUBSTR(IMGR.ORDER_NUMBER,1,2) DEPT_NO
    ,IMGR.PLAN_DESCRIPTION
    FROM XXI.IGL_MRP_GROSS_REQUIREMENTS IMGR
    WHERE IMGR.DEMAND_TYPE IN ('Discrete job','Non-standard job')
    AND IMGR.PLAN_DESCRIPTION ='MRP-PRODUCTION'
    AND IMGR.DEMAND_DATE <= :P_DATE
    AND SUBSTR(IMGR.ORDER_NUMBER,1,2) IN (&P_DEPT_NO)
    ORDER BY
    DEPT_NO
         ,MACHINE_NO
    ,IMGR.ASSEMBLY_DESCRIPTION
    ,IMGR.ASSY_ITEM_NUMBER
    ,IMGR.ORDER_NUMBER
    ,IMGR.ITEM_NUMBER
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_IGLOO_QA_FPI" source="ROW1">
    <element name="MACHINE_NO" value="MACHINE_NO"/>
    <element name="ORDER_NUMBER" value="ORDER_NUMBER"/>
    <element name="ASSY_ITEM_NUMBER" value="ASSY_ITEM_NUMBER"/>
    <element name="ASSEMBLY_DESCRIPTION" value="ASSEMBLY_DESCRIPTION"/>
    <element name="ITEM_NUMBER" value="ITEM_NUMBER"/>
    <element name="ITEM_DESCRIPTION" value="ITEM_DESCRIPTION"/>
    <element name="DEPT_NO" value="DEPT_NO"/>
    <element name="PLAN_DESCRIPTION" value="PLAN_DESCRIPTION"/>
    </group>
    </dataStructure>
    </dataTemplate>
    Please Share your ideas.
    Thank
    Aswath

    hi Ananth,
    i tried the logic but its also not printing the First Line.
    Syntax:
    <?if:ORDER_NUMBER!= ORDER_NUMBER?><?ORDER_NUMBER?><?end if?>
    I think this condition works fine if it is start from second line of the row.
    Output:
    S_NO Order_number Assy_item Assy_Desp Item_Number
    1     12345 TEST     1245
    2     12345 TEST     1256
    No Order_number displayed.
    i hope you got my point. Please help me to get through it.
    Thanks
    Aswath

  • Issues while joining two tables as the joining column has duplicate values - Please help!

    Hi,
    I have a table A -which has few columns including a Amount column - I am joining this table A to Table B. The joining column in B has duplicates.  So, the number of records are getting more after the joining. As per the requirment when I create a table
    after joining the tables and count the salary clumn, there is a difference in the counting. How can I solve this? Can you please help me?
    Here is the DDL and sample values
    create table #student (sid int, name varchar(10),salary int)
    create table [#address] (sid int, city varchar(10),grade char(1),lineneumber int)
    insert into #student values (1,'sachin',8000)
    insert into #student values (2,'Dhoni',2000)
    insert into #student values (3,'Ganguly',7000)
    insert into #student values (4,'Kohli',1000)
    insert into [#address] values(1,'mumbai','A',1)
    insert into [#address] values(1,'mumbai','B',2)
    insert into [#address] values(1,'mumbai','C',3)
    insert into [#address] values(1,'mumbai','D',4)
    insert into [#address] values(2,'JARKHAND','D',3)
    insert into [#address] values(2,'JARKHAND','D',4)
    SELECT S.SID,NAME,salary,CITY ,grade,linenumber
    into #FINAL
    FROM #STUDENT S
    LEFT JOIN #ADDRESS A
    ON S.SID=A.SID
    SELECT SUM(salary) FROM #FINAL
    --44000
    Final result should be 18000 , but it is coming as 44000. can you please help me to get the correct result - what do i do in the joining?
    In my real project, i have 5 tables joining, each table have more than 30 columns and few joining tables joining column have duplicates. I have simplified the issue so that i can ask the question clearly. So,while answering, please consider that also in mind.
    thanks in advance for your help!

    SELECT S.SID,NAME,salary,CITY 
    into #FINAL
    FROM #STUDENT S
    LEFT JOIN (SELECT DISTINCT sid,city
    FROM #Address) A
    ON S.SID=A.SIDthis will do a join on student table and city table with unique sid and city name so adddress selection will be sid city1 mumbai2 jarkand

Maybe you are looking for

  • Error while installing the client

    Hi, While installing the CRM Mobile client I get the following error "Requisite Version of JRE not found". The JDK version which I have installed is 1.4.2_13 and my class path settings seems to be fine. Kindly suggest regards, Arun

  • 'You've Been Signed Out' - Solutions not working

    Hi, I've been having this problem for many days now and have been very patient with the customer care team. However, I'm not approaching deadlines at University and really, really need access to Creative Cloud. I haven't even got any programs downloa

  • Firefox keeps "not responding" for a few seconds - then connects

    I just upgraded to Firfox 4.0 because of my new computer's Windows 7. It started "not responding" for up to 20 - 30 seconds before it reconnects, and it is sometimes unresponsive to my mouse even when it is working. This did not happen before the upg

  • Is this a good design?

    I am designing an online application. There is a super class DataItem and 3 subclasses. Also, each of the classes has a dao class with the same inheritance relationship. In each sub DAO class (extends DataItemDAO), it has its own getContentItems() me

  • OUTLOOK 2010 error "cannot sent this item"

    Hai, When i try to forwarding / replying via Outlook 2010, i am getting an error "Cannot send this item" .  The error occurred only when forwarding / replying a particular MAILS.