SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Is there a way to batch change the time?

    there are two columns as the following in my mysql database:

    Code:
        ID        time
        1          2012-02-05 14:15:54
        2          2012-02-05 14:15:54
        3          2012-02-05 14:15:54
        4         2012-02-05 14:15:54
        5          2012-02-05 14:15:54
        10         2012-02-05 14:15:54
    Now,i want to use a sql command(using in phpmyadmin) to update the time which is Optional in `(2011-01-05 14:15:54 ---2012-04-05 14:15:54)`


    i want to change this `2012-02-05 14:15:54` to another time which is in `(2011-01-05 14:15:54 ---2012-04-05 14:15:54)` eg:`2011-02-06 13:15:54 2011-05-06 11:15:54....`

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    could you repeat the question please?

    i don't understand what eg:`2011-02-06 13:15:54 2011-05-06 11:15:54....` means

    a column can hold only one value, it looks like you want to have a range?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    generate a new time randly which between (2011-01-05 14:15:54 ---2012-04-05 14:15:54) then replace the old time in time column

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Code:
    UPDATE daTable SET `time` = `time` + INTERVAL -30 + RAND(id)*90 DAY
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •