SQL UPDATE command for updating DATE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suresh4ind
    New Member
    • Apr 2007
    • 11

    SQL UPDATE command for updating DATE

    Hi
    how can i update the DATE field in a table
    my code is

    UPDATE FACTORYORDER
    SET DUEDATE =7/30/2001
    WHERE olddate =1/6/2004

    showing error
    suggest me where i need to change
  • DeMan
    Top Contributor
    • Nov 2006
    • 1799

    #2
    Hi there, just moving your post to one of the SQL forums, where the experts will be far better qualified to address your query. A link to this thread will be left in the introductions this time, however in future you can use the blue bar above to navigate through the forums

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by suresh4ind
      Hi
      how can i update the DATE field in a table
      my code is

      UPDATE FACTORYORDER
      SET DUEDATE =7/30/2001
      WHERE olddate =1/6/2004

      showing error
      suggest me where i need to change
      Hi and Welcome to TSDN. Hope you'll have a great time here.
      You should have specified the error that you're getting and posted this in a relevant database forum.
      Which database are you using e.g with MySQL you'd have to do

      [CODE=sql] UPDATE FACTORYORDER
      SET DUEDATE ="2001-301-07"
      WHERE olddate ="2004-06-01"[/CODE]

      Comment

      • suresh4ind
        New Member
        • Apr 2007
        • 11

        #4
        Hi
        im updating the database using TOAD for Oracle freeware
        code :
        UPDATE FACTORYORDER
        SET DUEDATE ="2001-30-07"
        WHERE olddate ="2004-06-01";

        error is : 2004-06-01 is invalllid identifier

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by suresh4ind
          Hi
          im updating the database using TOAD for Oracle freeware
          code :
          UPDATE FACTORYORDER
          SET DUEDATE ="2001-30-07"
          WHERE olddate ="2004-06-01";

          error is : 2004-06-01 is invalllid identifier
          In that case I'll move this to the Oracle forum .

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            Originally posted by suresh4ind
            Hi
            im updating the database using TOAD for Oracle freeware
            code :
            UPDATE FACTORYORDER
            SET DUEDATE ="2001-30-07"
            WHERE olddate ="2004-06-01";

            error is : 2004-06-01 is invalllid identifier
            write
            [code=oracle]
            update factoryorder set duedate='30-jul-01' where olddate='06-jan-04'
            [/code]

            this will solve your problem

            Comment

            • tayalpooja000
              New Member
              • Jun 2007
              • 3

              #7
              Originally posted by suresh4ind
              Hi
              how can i update the DATE field in a table
              my code is

              UPDATE FACTORYORDER
              SET DUEDATE =7/30/2001
              WHERE olddate =1/6/2004

              showing error
              suggest me where i need to change

              use single quotes arround date becoz default is char data type

              UPDATE FACTORYORDER
              SET DUEDATE ='7/30/2001'
              WHERE olddate ='1/6/2004'

              Comment

              • myselfchinmay
                New Member
                • Jun 2007
                • 1

                #8
                Originally posted by suresh4ind
                Hi
                how can i update the DATE field in a table
                my code is

                UPDATE FACTORYORDER
                SET DUEDATE =7/30/2001
                WHERE olddate =1/6/2004

                showing error
                suggest me where i need to change

                HI,
                DO THE FOLLOWING:
                1.USE THIS QUERY : SELECT DUEDATE,OLDDATE FROM FACTORYORDER;
                2.CHECK THE DATATYPE OF THIS TWO FIELDS AND THEN CHECK THE DATE FORMAT FOR THESE FIELDS.
                3.NOW USE THIS QUERY FOR UPDATE:
                UPDATE FACTORYORDER SET DUEDATE='30-JUL-2001' WHERE OLDDATE='06-JAN-2004';

                NOTICE : ABOVE QUERY WILL UPDATE ALL THE RECORDS HAVING OLDDATE AS '06-JAN-2004'. BE SURE BEFORE COMMIT.

                Comment

                • suresh4ind
                  New Member
                  • Apr 2007
                  • 11

                  #9
                  Thanks to all particularly Mr Debasisdas,i got my answer

                  Comment

                  Working...