This discussion is archived
1 2 Previous Next 17 Replies Latest reply: Dec 10, 2012 9:12 AM by rp0428 RSS

Strange dates/times in the DB

978688 Newbie
Currently Being Moderated
Somehow the following DATE field data (this is from a SQL*Plus query that did not manipulate the date just did a straight-up query, so the format is our default) is in our database:

*2012/10/22 27:22:30*

How did it get in there with hours like that? I have tried a few different insert statements and I can't find a way to get a date like that into the database. There is no date arithmetic done on it on this server, it's probably coming from another machine/server just like that (still trying to track that down). Does SQL*Loader or some other method bypass Oracle's date validation or is there something else I'm missing?

It's an Oracle DB (10.2.0.1.0) and it is just a standard DATE field.
  • 1. Re: Strange dates/times in the DB
    sb92075 Guru
    Currently Being Moderated
    975685 wrote:
    Somehow the following DATE field data (this is from a SQL*Plus query that did not manipulate the date just did a straight-up query, so the format is our default) is in our database:

    *2012/10/22 27:22:30*

    How did it get in there with hours like that? I have tried a few different insert statements and I can't find a way to get a date like that into the database. There is no date arithmetic done on it on this server, it's probably coming from another machine/server just like that (still trying to track that down). Does SQL*Loader or some other method bypass Oracle's date validation or is there something else I'm missing?

    It's an Oracle DB (10.2.0.1.0) and it is just a standard DATE field.
    I don't believe you.


    How do I ask a question on the forums?
    SQL and PL/SQL FAQ
  • 2. Re: Strange dates/times in the DB
    cmsneed Newbie
    Currently Being Moderated
    Is there a script that does an ALTER SESSION SET NLS_DATE_FORMAT when you log on?

    SQL> alter session set NLS_DATE_FORMAT='YYYY/MM/DD MI:HH24:SS';

    Session altered.

    SQL> select sysdate from dual;

    SYSDATE
    -------------------
    2012/12/07 51:15:19
  • 3. Re: Strange dates/times in the DB
    978688 Newbie
    Currently Being Moderated
    No, no 'alter session' command. Easily repeatable by other people in my group. Even better, if you run the same query in SQL*Developer the same date comes up as:

    *23-OCT-12 03.22.30*

    The default NLS Format for DATE on my SQL*Developer is:

    DD-MON-RR HH24.MI.SS

    The default NLS Format for DATE on that server is:

    DD-MON-RR HH24.MI.SS

    How 'bout that?!
  • 4. Re: Strange dates/times in the DB
    VijayaraghavanKrishnan Pro
    Currently Being Moderated
    HI,

    Try setting up the NLS_DATE_FORMAT for the session in sql*plus and let us know the output.
    Alter session set NLS_DATE_FORMAT = 'DD-MON-YY HH24:MI:SS'
    Thanks,
    Vijay
  • 5. Re: Strange dates/times in the DB
    978688 Newbie
    Currently Being Moderated
    Did the alter session and the date comes back as:

    *22-OCT-12 27:22:30*
  • 6. Re: Strange dates/times in the DB
    VijayaraghavanKrishnan Pro
    Currently Being Moderated
    Sorry I want to try different and gave you the different format
    Alter session set NLS_DATE_FORMAT = 'DD-MON-YY HH:MI:SS AM'
    Thanks,
    Vijay
  • 7. Re: Strange dates/times in the DB
    978688 Newbie
    Currently Being Moderated
    Altered the session as stated and the date comes up as:

    *22-OCT-12 15:22:30 PM*
  • 8. Re: Strange dates/times in the DB
    rp0428 Guru
    Currently Being Moderated
    >
    Somehow the following DATE field data (this is from a SQL*Plus query that did not manipulate the date just did a straight-up query, so the format is our default) is in our database:

    2012/10/22 27:22:30

    How did it get in there with hours like that? I have tried a few different insert statements and I can't find a way to get a date like that into the database. There is no date arithmetic done on it on this server, it's probably coming from another machine/server just like that (still trying to track that down). Does SQL*Loader or some other method bypass Oracle's date validation or is there something else I'm missing?

    It's an Oracle DB (10.2.0.1.0) and it is just a standard DATE field.
    >
    Well I've never known the DUMP function to lie about what it finds so show us that result
    SELECT dateColumn, DUMP(dateColumn) from myTable;
  • 9. Re: Strange dates/times in the DB
    Mark Malakanov (user11181920) Expert
    Currently Being Moderated
    show us entirely all sql statements you executed. not just result.
  • 10. Re: Strange dates/times in the DB
    VijayaraghavanKrishnan Pro
    Currently Being Moderated
    HI,

    Is this a SYSDATE OUTPUT? Please post the OS

    Thanks,
    Vijay

    Edited by: Vijayaraghavan Krishnan on Dec 7, 2012 3:27 PM
  • 11. Re: Strange dates/times in the DB
    Osama_Mustafa Oracle ACE
    Currently Being Moderated
    The db gets its time from the OS So Post Date Command in your OS level
  • 12. Re: Strange dates/times in the DB
    978688 Newbie
    Currently Being Moderated
    This is not SYSDATE output. The sequence of queries and alters as per your requests were:

    SELECT CURE_DT FROM RT_TIRE WHERE BARCODE = '61790283';

    CURE_DT
    -------------------
    2012/10/22 27:22:30

    ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YY HH24:MI:SS';

    Session altered.

    SELECT CURE_DT FROM RT_TIRE WHERE BARCODE = '61790283';

    CURE_DT
    -------------------
    22-OCT-12 27:22:30

    ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YY HH:MI:SS AM';

    Session altered.

    SELECT CURE_DT FROM RT_TIRE WHERE BARCODE = '61790283';

    CURE_DT
    -------------------
    22-OCT-12 15:22:30 PM

    SELECT CURE_DT, DUMP(CURE_DT) FROM RT_TIRE WHERE BARCODE = '61790283';

    CURE_DT
    ------------------------------
    DUMP(CURE_DT)
    --------------------------------------------------------------------------------
    22-OCT-12 15:22:30 PM
    Typ=12 Len=7: 120,112,10,22,28,23,31
  • 13. Re: Strange dates/times in the DB
    Mark Malakanov (user11181920) Expert
    Currently Being Moderated
    22-OCT-12 27:22:30
    22-OCT-12 15:22:30 PM
    It looks like the value is corrupted. It may be corrupted in 2 places - in table and in index(exes) that have CURE_DT.

    find index from plan of
    SELECT CURE_DT FROM RT_TIRE WHERE BARCODE = '61790283';

    and try to rebuild it if it contains CURE_DT.
  • 14. Re: Strange dates/times in the DB
    VijayaraghavanKrishnan Pro
    Currently Being Moderated
    Hi,

    Post us the sysdate output and as well the OS date.

    Is your output from sysdate is displaying properly? Even though if your record got corrupted too the Oracle should will throw the error when it returns, insert the date if it is not properly entered.

    In your case it is returning 22-OCT-12 27:22:30. Oracle should throw the error if it is the date datatype.

    Thanks,
    Vijay

    Edited by: Vijayaraghavan Krishnan on Dec 10, 2012 10:28 AM
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points