Jump to content

Date Comarision


kumarrana

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.