How to update a table setting date as '11/30/2010 12:30:01 PM' in particular records?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • seemantika
    New Member
    • Dec 2010
    • 1

    How to update a table setting date as '11/30/2010 12:30:01 PM' in particular records?

    kindly plz anyone can tell me what is the query for updating a table having one column createddatetime which is like '11/30/2010 12:30:01 PM'. i want to set some more records to that values using update command. how?
    i can do it using for update.. by manually one by one...
    but how to do it using update command? plz help me in this..
    i tried this command Like this
    "update <table_name> a
    set a.createddateti me=to_char('11/30/2010 12:30:01 PM','mm/dd/rrrr hh:nn:ss PM')
    where ......."

    but it shows invalid number error...
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    Maybe like that
    Code:
    update <table_name> a
    set a.createddatetime=to_char('11/30/2010 12:30:01 PM','mm/dd/rrrr hh:mi:ss PM')

    Comment

    • amitpatel66
      Recognized Expert Top Contributor
      • Mar 2007
      • 2358

      #3
      Try this:

      [code=oracle]
      SQL> ed
      Wrote file afiedt.buf

      1* UPDATE test_1 set a = TO_CHAR('11/30/2010 12:30:01 PM','MM/DD/RRRR HH:MI:SS PM')
      SQL> /
      UPDATE test_1 set a = TO_CHAR('11/30/2010 12:30:01 PM','MM/DD/RRRR HH:MI:SS PM')
      *
      ERROR at line 1:
      ORA-01722: invalid number


      SQL> ed
      Wrote file afiedt.buf

      1* UPDATE test_1 set a = TO_DATE('11/30/2010 12:30:01 PM','MM/DD/RRRR HH:MI:SS PM')
      SQL> /

      1 row updated.

      SQL> select TO_CHAR(a,'MM/DD/RRRR HH:MI:SS PM') from test_1;

      TO_CHAR(A,'MM/DD/RRRRH
      ----------------------
      11/30/2010 12:30:01 PM

      SQL>


      [/code]

      Comment

      Working...