Support » Fixing WordPress » Update post_date_gmt with values from post_date

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Andrew Ozz

    (@azaozz)

    WordPress Dev

    I’m not that good with SQL, but you will need to do UPDATE, not SELECT to change the dates. Looking at upgrade-functions.php (in WP) the syntax is something like:

    UPDATE wp_posts WHERE post_date_gmt = 0 SET post_date_gmt = DATE_ADD(post_date, INTERVAL '03:00' HOUR_MINUTE) LIMIT 1

    Try it with LIMIT 1 first to see if it works right. And of course you need to have db backup 🙂

    Okay, I’ll try that, but can I get the logic first. (I like to learn as I do).

    I understand the UPDATE and the WHERE. Is the DATE_ADD a mysql function?

    Moderator Andrew Ozz

    (@azaozz)

    WordPress Dev

    I’m getting the following error

    You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE post_date_gmt = 0 SET post_date_gmt = DATE_ADD(post_

    It looks like the UPDATE query is being cut off at post_ (Or the error only repeats so many characters of my query)

    Moderator Andrew Ozz

    (@azaozz)

    WordPress Dev

    Hmmm it stops at WHERE, perhaps the WHERE has to come after the SET, like that:

    UPDATE wp_posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '03:00' HOUR_MINUTE) WHERE post_date_gmt = 0 LIMIT 1

    Worked like a charm. Thanks so much for your help.

    Finally! Was cleaning out old blogger import issues and I realized that there were a bunch of missing gmt times!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Update post_date_gmt with values from post_date’ is closed to new replies.