Jump to content

Recommended Posts

This will convert your string to a mysql DATE type and add seven days.

$sql = "SELECT STR_TO DATE(datecol, '%M $d, %Y') + INTERVAL 7 DAY"; 			

 

But as DW said, better to change to mysql DATE type (format YYYY-MM-DD) as most other formats, such as yours, are of zero use as DB dates. You can use that same STR_TO DATE function to update your table.

Link to comment
https://forums.phpfreaks.com/topic/118697-date-comarision/#findComment-611175
Share on other sites

It is not necessary to use any php code to fix date columns.

 

1) Backup your database.

 

2) Alter your table to add a new column of the correct type.

 

3) Run an UPDATE query (using the mysql STR_TO DATE() function) to populate the new column with the equivalent values from the existing column.

 

4) Modify and test your code to correctly use the new column.

 

5) Remove the old column.

Link to comment
https://forums.phpfreaks.com/topic/118697-date-comarision/#findComment-612690
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.