Trigger returning different date formats.

Posted from Windows forum:
We just reticently received a update to an .net application from a vendor. When our client machines (Windows XP) run the app we receive 2 different date formats returned from an post insert table trigger. The correct format is 'DD-MON-YY' in which a couple machines still return and the others return the format 'YYYY-MM-DD HH24:MM:SS'. I've tried setting the NLS_Date Format with no success. Database is Oracle 8i. Any suggestions?

CREATE TABLE X.ACCESS_LOG
ACCESS_LOG_ID NUMBER NOT NULL,
SYS_ID NUMBER NOT NULL,
DATE_IN DATE NOT NULL,
DATE_OUT DATE NOT NULL,
INSTRUMENT_ID_IN NUMBER,
INSTRUMENT_ID_OUT NUMBER,
STATION_IN VARCHAR2(20),
STATION_OUT VARCHAR2(20),
AREA_IN VARCHAR2(25),
AREA_OUT VARCHAR2(25)
CREATE OR REPLACE TRIGGER XFER_TO_TRACKING
AFTER INSERT
ON x.ACCESS_LOG
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
     v_qtr Number;
BEGIN
SELECT qtr
INTO v_Qtr
FROM X.QTR_SET
WHERE to_date(:new.Date_In,'dd-mon-yy') BETWEEN first_date AND last_date;
Insert (....)
END/
Here is the basic code for table and trigger. When the trigger fires the value for :new.date_in will come over in the format of "dd-mon-yy", which we have been looking for, or "YYYY-MM-DD HH24:MM:SS" which just came up with this new release depending on which station is used.

Similar Messages

  • Problem with SQL*Loader and different date formats in the same file

    DB: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    System: AIX 5.3.0.0
    Hello,
    I'm using SQL*Loader to import semi-colon separated values into a table. The files are delivered to us by a data provider who concatenates data from different sources and this results in us having different date formats within the same file. For example:
    ...;2010-12-31;22/11/1932;...
    I load this data using the following lines in the control file:
    EXECUTIONDATE1     TIMESTAMP     NULLIF EXECUTIONDATE1=BLANKS     "TO_DATE(:EXECUTIONDATE1, 'YYYY-MM-DD')",
    DELDOB          TIMESTAMP     NULLIF DELDOB=BLANKS          "TO_DATE(:DELDOB, 'DD/MM/YYYY')",
    The relevant NLS parameters:
    NLS_LANGUAGE=FRENCH
    NLS_DATE_FORMAT=DD/MM/RR
    NLS_DATE_LANGUAGE=FRENCH
    If I load this file as is the values loaded into the table are 31 dec 2010 and 22 nov *2032*, aven though the years are on 4 digits. If I change the NLS_DATE_FORMAT to DD/MM/YYYY then the second date value will be loaded correctly, but the first value will be loaded as 31 dec *2020* !!
    How can I get both date values to load correctly?
    Thanks!
    Sylvain

    This is very strange, after running a few tests I realized that if the year is 19XX then it will get loaded as 2019, and if it is 20XX then it will be 2020. I'm guessing it may have something to do with certain env variables that aren't set up properly because I'm fairly sure my SQL*Loader control file is correct... I'll run more tests :-(

  • Different Date Formats in the same "From"

    Hello
    We used different date formats depending on the users language.
    In a report this is simple to implement ... read the date field twice (in different formats dd/mm/yyyy and mm/dd/yyyy) and display only one based on the language.
    I want to be able to do the same in a "form" which updates a date. In this case the about is not allowed.
    Has anyone have solution for this using "APEX" forms or do a need to write a process to achieve this?
    Thanks
    Pete

    Pete,
    You don't specify what version of Application Express you're using, so I'll assume APEX 3.1 or later.
    Are you setting the date format yourself, based upon the user's language?
    1) You could have the application's language derived from Browser, and then APEX would automatically set the NLS_LANGUAGE and NLS_TERRITORY settings accordingly. Then, I would simply use 'DS' as the Application Date Format. For Date Pickers on a form, I would use item type 'Date Picker (use Application Date Format)'.
    2) If you're already determining the date format yourself and you don't want APEX to do it for you, ensure that you are setting this value in an application item (e.g., PETE_DATE_FORMAT). Then, you could still use Application Date Format with a value of &PETE_DATE_FORMAT. (inclusive of the trailing period).
    When you use Application Date Format, the conversion should happen automatically for you so that you don't have to code this yourself on the Form.
    I hope this helps.
    Joel

  • URGENT: XML-SQL: Error parsing different date formats in the same XML file.

    Hi Everyone,
    I have a big problem while using the XML-SQL utility. I have a XML file with different date formats. I get exception like the one below.
    "oracle.xml.sql.OracleXMLSQLException: 'java.text.ParseException: Unparseable date:"
    And the XML file is :
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Info Key="ID">
         <Insert>
              <ID>1</ID>
              <BookingDate>10.12.2001</BookingDate>
              <OpeningTime>19:16</OpeningTime>
         </Insert>
    </Info>
    I have tried using different setDateFormat which is contrary.
    sav.setDateFormat("d.M.y");
    sav.setDateFormat("H:m:s");
    Can someone help me on the same.
    Thanks in advance.
    Subramanian.

    You might have to describe the columns as varchar then modify the table to the right format.

  • Different Date Formats on CRM and BI Client

    Hi,
    When trying to run the CRM Interactive Report "Accounts with Open Activities", I receive the following error:
    Different date formats on CRM and BI client 01/13/2009 13.01.2009 SC5CLNT200
    Does anybody know how to resolve this error?
    Thanks

    Hi Peter,
    As far as i remember, I had the same issue.
    Once I matched the date format in reporting client using SU01 on default tab with CRM date format, I did't see the error again.
    Did you try restarting the Browser & also relogin GUI.
    Else lets see what else can be done.
    Best Regards
    Shiven

  • Different Date Format

    Hi All,
    I'm using OWB,Disc Admin and Disc Plus. The problem i'm having is, In the OWB Target Table i have a date field in the following format "DD-MM-YYYY HH:MM:SS AM/PM", but when i bring the filed into a report in Disco Plus i'm seeing it in the format "DD-MM-YYYY". I went onto Disco Admin and opened the folder and edited the Date field to the "DD-MM-YYYY HH:MM:SS" field, but still its not showing the changes made in Admin. Any suggestions why its showing different date formats?
    Thanks

    Hi
    Discoverer shows dates as dates. The time elements are still there. If you want to see them use the TO_CHAR function.
    Best wishes
    Michael

  • How to handle different date formats ?

    I'm currently writing an application that has to be compatible with different database backends.
    But I have some problems with the date/time fields when using Oracle as a db backend:
    After searching the forums, I found a solution for my "inserts" problem:
    // This is needed because otherwise the db session will be reset with each jdbc call,
    // ending the session and nullifying the ALTER SESSION command
    con.setAutoCommit( false );
    // set the date/time format to what we want it to be
    result = stmt.executeQuery("ALTER SESSION SET NLS_DATE_FORMAT = 'dd/mm/yyyy hh24:mi:ss'");
    res = stmt.executeUpdate(query);
    Where query is something like "INSERT INTO DATE_TEST VALUES ('val1',"val2','val3','25/03/2004 15:59:44');
    But when I want to retrieve this data, the timestamp is returned in another format:
    result = stmt.executeQuery("SELECT * FROM DATE_TEST");
    This gives me "2004-03-25 15:59:44.0" for the timestamp !
    when I run exactly the same query in the Oracle SQL*Plus console, I get the correct format:
    SQL> SELECT * FROM DATE_TEST;
    VAL1 VAL2 VAL3 TIME
    val1 val2 val3 25/03/2004 15:59:44
    SQL>
    I already tried the trick with the NLS_DATE_FORMAT before retrieving the data, but that doesn't seem to do anything.
    Any ideas how I can manipulate the format of a DATE field for retrieval ?
    Note:
    This is what I use:
    - Oracle 9i, Release 2 (9.2.0.1.0) for Windows (on windows 2000 Server)
    - ojdbc14.jar (Oracle thin jdbc driver)
    - j2sdk 1.4.2-04 for my application (currently running on windows server 2003 Enterprise, but is also tested on windows 2000, xp, linux, solaris)

    well, in fact I wrote a "dbAdapter" which I use to let my application communicate with a database.
    the method I use to retrieve data from the db just reads the resultset row by row, adding each row to a
    vector.
    each row is represented by a hashtable (colname - colvalue pairs).
    Vector result = dbadapter.queryDB("SELECT * FROM DATE_TEST");
    the method "query" looks like this:
    public Vector queryDB(String query) {
    Connection con = null;
    ResultSet result = null;
    ResultSetMetaData metadata = null;
    Vector tableData = new Vector();
    Statement stmt = null;
    try { // Attempt to load the JDBC driver with newInstance
    Class.forName(sDriver).newInstance();
    catch (Exception e) { // error
    logger.error(logPrefix + "Failed to load current driver.");
    if (psStackTrace != null)
    e.printStackTrace(psStackTrace);
    return tableData;
    } // end catch
    try {
    con = DriverManager.getConnection(sURL, sUsername, sPassword);
    // stmt = con.createStatement(); // MySQL
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); // TODO-ORACLE
    catch (Exception e) {
    logger.error(logPrefix + "problems connecting to " + sURL + ":" + e.getMessage());
    if (psStackTrace != null)
    e.printStackTrace(psStackTrace);
    if (con != null) {
    try {
    con.close();
    catch (Exception e2) {
    return tableData;
    } // end catch
    // execute SQL commands
    try {
    result = stmt.executeQuery(query);
    // first display some metadata
    metadata = result.getMetaData();
    int numcols = metadata.getColumnCount(); // How many columns?
    result.last(); // Move to last row
    int numrows = result.getRow();
    Hashtable rowData = new Hashtable();
    String colValue = "", colName = "";
    Object o = null;
    for (int a = 0; a < numrows; a++) {
    result.absolute(a + 1); // go to row a in resultset
    for (byte b = 0; b < numcols; b++) {
    o = result.getObject(b + 1);
    colName = metadata.getColumnName(b + 1);
    if (o == null) {
    colValue = "";
    else {
    colValue = o.toString();
    rowData.put(colName, colValue);
    tableData.add(rowData.clone());
    rowData.clear();
    // return result
    return tableData;
    catch (Exception e) {
    logger.error(logPrefix + "problem with SQL sent to " + sURL + ":" + e.getMessage());
    logger.debug(logPrefix + "sql: " + query);
    if (psStackTrace != null)
    e.printStackTrace(psStackTrace);
    finally {
    try {
    stmt.close();
    catch (Exception e) {
    try {
    con.close();
    catch (Exception e) {
    } // end finally clause
    return tableData;
    then I display the data using this code (output goes to a logfile):
    for (int i = 0; i < result.size(); i++) {
    Hashtable tmpResultTable = (Hashtable) result.elementAt(i);
    Enumeration enum = tmpResultTable.keys();
    while(enum.hasMoreElements()) {
    String tmpKey = (String) enum.nextElement();
    String tmpValue = (String) tmpResultTable.get(tmpKey);
    logger.debug(logPrefix + "\t- " + tmpKey + "=" + tmpValue);
    It is correct indeed that I want to keep it as vendor neutral as possible, because other databases will
    be added in the (near) future (such as IBM's DB2)
    I already thought about formatting it using the SimpleDateFormat class, but then I have to rewrite most
    of the code in my dbAdapter, because it doesn't know anything about the field types.
    It just launches standard SQL queries and returns the result back to the requesting object

  • How to extract  different date format in text file

    well, iam new for using regex api(regular expression), In my project i want to extract the different format of date from the text file... date format will be 3rd june 2004, 03-06-2004, june 3rd and so on....
    can any body give me regular expression to extract the date from the text file...
    i will be very grateful..
    kareem

    date format will be 3rd june 2004, 03-06-2004, june 3rd and so on....The only way to do this (without implementing a "mind reader") is to determine in advance all the possible date formats that are possible in your input, and try to interpret each date using each of those formats until one of them passes.
    It's easy enough to handle june 3rd vs 3 june vs 3rd june, but 6/3 vs 3/6, of course, is ambiguous.

  • Why are 2 different date formats being used in thunderbird?

    Hello
    in the attachment you will see that the listing of emails (on the left) is shown using UK date format DD/MM/YY (that's what I want), however, the message content panel shows the date in the US format MM/DD/YY (I definitely do not want this).
    Why are 2 different formats being applied in Thunderbird, and how can I get both to be UK DD/MM/YY please.
    Many thanks
    Lord Elpus

    I should have said :
    this is Thunderbird 31.6.0 on Ubuntu 14.04 LTS
    Image resent due to previous failure.

  • Different date format in different database..

    Hi,
    We have two database (10g) with same NLS settings.When we are reading the data from a table and assigning the value to XML tags using oracle.xml.sql.query.OracleXMLQuery class , with one database connection, the data format is coming as MM/DD/YYYY like <PYMT_DATE>7/23/2008 0:0:0</PYMT_DATE>
    but with other database it is coming as YYYY-MM-DD like <PYMT_DATE>2009-08-10</PYMT_DATE>..
    Can somebody help me out ?

    hi..
    Check the data format used to retrieve the date in the query ..
    TO_DATE (......................)
    Check whether both the db's are having same conversions..

  • CalendarUI element showing different date format for different locations

    Hi,
    I have an input field with date calendar in my webdynpro Java form . User can select date from this calendar and fill the input field. For this I have used input field  in my layout and have binded this with one context attribute of type date. Say name of this field is requiredByDate
    Now when I build and deploy my code, I can see the the required By date field and user is able to select date values from the calendar button next to the input field. The format of the date selected is mm/dd/yyyy.
    However , when a user tests this application from other location say Malaysia, for him the format is coming as dd/mm/yyyy after selecting the date from the calendar.
    Just want to know ,is there is difference in date format for differnt locations ? For India, when you select the date its showing mm/dd/yyyy and for Malayisa its showing dd/mm/yyyy.
    Is there anything we can do by changing our system settings like timezone or dateformat in system settings.
    I am using standard UI element and binding it with context element of type date.
    Need your advice or help on this..
    Thanks and regards,
    Sai

    Hi,
    go to
    [http://help.sap.com/saphelp_nw04/helpdata/en/f4/d95664da179b4db731e21c2e470b72/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/en/f4/d95664da179b4db731e21c2e470b72/frameset.htm]
    It describes the fallback sequence followed by the Web Dynpro for Java Runtime in order to determine the current session locale.
    Regards
    Matteo

  • Receiving error when calculating two fields with different date format

    I am more familiar with SQL Server than Oracle, so after searching online without success, I am asking here.
    I'm using PL/SQL Developer with Oracle DB 11g Enterprise Release 11.2.0.2.0 64 Bit
    MyTable:
    ID_Number     VarChar2
    Date_Received     Date
    Select ID_Number,
         Date_Received,
         To_Date(substr(ID_Number, 1,6), 'YYMMDD') SentDate,    
         Date_Received - To_Date(substr(ID_Number, 1,6), 'YYMMDD') NumDays
    From MyTable
    Where substr(ID_Number, 7,3) in ('ABC', 'ABD')
    and Length(Trim(Translate((substr(ID_Number, 1,6)), '0123456789', ' ' ))) is null
    ID_Number                    Date_Received          SentDate          NumDays
    131002ABC1654106     10/16/2013               10/2/2013          14
    131004ABD8813899     4/12/2013                 4/8/2013            4
    131014ABD1844832     10/16/2013               10/14/2013          2
    Sometimes the first 6 characters in the ID_Number are not numbers, and the Length(Trim(Translate removes those records
    I just want records where NumDays > 2
    I've tried putting the query in a subquery and using Where NumDays > 2 outside.  I've also tried using the computation directly in the Where clause.  Without this in the Where clause it runs fine, with it in either spot I get the following error:
    ORA-01931: Date format picture ends before converting entire input string
    I'm not sure how to put both dates in the same format.  I've tried declaring the format to no avail.  I do not understand how I can calculate within the select but not use the same calculation within the Where clause.
    Thank you for your help.

    Hi,
    SQL is a language for describing the results you want.  How the system gets those results is up to it; you don't have much say regarding which conditions will be applied when.
    One place where you can control the order of things is in a CASE expression.  When you say
    CASE
        WHEN  condition_1
        THEN  expression_1
    END
    you can be sure that expression_1 will only be evaluated when cond_1 is TRUE.
    Try something like this:
    WITH  got_sent_date AS
        SELECT  id_number, date_received
        ,       CASE
                    WHEN  TRANSLATE ( SUBSTR (id_number, 1, 6)
                                    , 'x 0123456789'
                                    , 'x'
                                    )  IS NULL
                    THEN  TO_DATE ( SUBSTR (id_number, 1 6)
                                  , 'YYMMDD'
                END     AS sent_date
        FROM    MyTable
        WHERE   SUBSTR (id_number, 7, 3) IN ('ABC', 'ABD')
    SELECT  id_number
    ,       date_received
    ,       sent_date
    ,       date_received - sent_date    AS num_days
    FROM    got_sent_date
    WHERE   date_received  > sent_date + 2
    If you'd care to post some sample data (CREATE TABLE and INSERT statements) and the results you want from that data, then I could test this.
    Of course, you'll still have run-time errors if id_number starts with 6 digits, but they don't happen to be valid, e.g. '131100' or '130229'.  That's one of the many reasons why storing date information in VARCHAR2 columns is such a bad idea.  To get around that problem, see
    https://forums.oracle.com/message/4255051

  • Date comparision issue with different date formats

    Hi Friends
    I am trying to find difference in hours between two dates but not able to do that as the formats of both dates that i have are different.
    But i have both the dates in the String format. belwo is my code.
    First Date is in the format - yyyy-MM-dd-HH.mm.ss.SSS. String sDate = "2011-05-29-13.50.44.050761";
    Secong date is in the format - yyyy-MM-dd HH.mm.ss String uiDate = "2011-05-29 13.50.44";
    Now i need to parse both the Strings into a Date object and format that so that i can subtract both dates using the
    long difference = uiDate .getTime() - sDate.getTime();
    Can you please let me know how i can do that as the format of both the dates are different.
    Is there a way like a common format to which these both can be converted and calculation done.
    any suggestions and solutions would be of great help.

    Thanks All for your suggestions
    well i figured out the solution with some goggling and r&d.
    For the first case I was getting the Date and Time fields from the UI as two different fields. I then combined these into a Date object and set the format for the first date as yyyy-MM-dd-HH.mm.ss.SSS.
    The second date was already in the above format. Then the i just did the Date comparison and got the difference in hours which was what i wanted.
    Vikeng

  • Different date formats

    Want to find out what format was used in the access database for date fields. I had loaded the data from access to oracle temporary table by making all fields(columns)as character types and now trying to load in to actual tables in Oracle.
    The converted records has date entered something like '30 may 03' or '7/23/03'. I am using a to_date function to convert this to date and getting an error 'ORA-01843 :Not valid Month' exception.
    Is there a way to find out what format has used so that I can use the appropriate format mask in my to_date function.
    Any kind of help would be appreciated.
    Thanks,
    Sashi.

    Did you try loading this data into Oracle table with a column of DATE type? Did you get any errors when you tried that? Was there a reason of loading it into a VARCHAR2 column?
    I do not know how you loaded the data, but now you could do something like this:
    SQL> create table test (dt varchar2(20)) ;
    Table created.
    SQL> insert into test values ('01/01/03') ;
    1 row created.
    SQL> insert into test values ('30 may 03') ;
    1 row created.
    SQL> select decode(instr(dt, '/'), 0, to_date(dt, 'dd mon yy'), to_date(dt, 'dd/mm/yy')) from test ;
    DECODE(INST
    01-JAN-2003
    30-MAY-2003
    2 rows selected.
    SQL>

  • Different date format conversion?

    consider,
    i have a input like
    13/12/2008 (dd/mm/yyyy) or 13-12-2008,
    I want to change the above format to 12/13/2008 (mm/dd/yyyy) or 12-13-2008.
    Is it possible? Is there any function available?
    Please advise.

    Parse your date into a Date using a DateFormat/SimpleDateFormat.
    Then format that Date to a String using another DateFormat/SimpleDateFormat.

Maybe you are looking for