Insert Date

Discussion in 'Databases' started by tgotch, Oct 24, 2009.

  1. #1
    Hi,
    I just imported about 1000 records into mysql db.

    There is a date field "created", which I missed, and all the dates in the db read:
    0000-00-00 00:00:00

    Is there a way to easily change all the date fields to one date?

    I am not real experienced with dbs. :)
     
    tgotch, Oct 24, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Yes, run something like this.

    UPDATE my_table SET date_field = NOW();

    or

    UPDATE my_table SET date_field = '2005-01-05 00:00:00';
     
    jestep, Oct 24, 2009 IP
  3. chandan123

    chandan123 Prominent Member

    Messages:
    11,586
    Likes Received:
    578
    Best Answers:
    0
    Trophy Points:
    360
    #3
    UPDATE my_table SET date_field = '2009-09-09 00:00:00'; one shot
     
    chandan123, Oct 24, 2009 IP
  4. tgotch

    tgotch Guest

    Messages:
    337
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #4
    As I mentioned, kinda dumb when it comes to db.

    Where/how exactly do I run this update?
     
    tgotch, Oct 24, 2009 IP
  5. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #5
    Do you have ssh or phpmyadmin? You need to run that script in a command line prompt. phpmyadmin has one. Otherwise if you have SSH access to the server, you can run it directly from there.
     
    jestep, Oct 24, 2009 IP
  6. hina87

    hina87 Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    you can use update query to update existing record. You can insert current date using date('y-m-d') it will insert current date to mysql field
     
    hina87, Oct 24, 2009 IP
  7. jpatrick85

    jpatrick85 Member

    Messages:
    74
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #7
    If you don't use PHPMyAdmin, just use the same script you used to upload the data in the first place. But instead of INSERT queries, you'll have the one UPDATE query.
     
    jpatrick85, Oct 25, 2009 IP
  8. vlwebhosting

    vlwebhosting Guest

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    i had same problem
     
    vlwebhosting, Nov 12, 2009 IP