Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL DATE_ADD - date is wrong?
    text
    copied!<p>So I've got a simple query in MySQL that sets a new member's expiration date once they pay their dues:</p> <pre><code>UPDATE members SET joined=CURDATE(), expires=DATE_ADD(CURDATE(), INTERVAL 1 YEAR), active='1' WHERE id=1000 </code></pre> <p>this query has run 200+ times, normally with the correct result - the current date is put in the joined field, and a year from that date in the expires field. However, in about 10 instances, the expires date has been set to 00-00-0000 with no obvious explanation. I started writing the query to a text file every time to make sure the syntax was correct and I hadn't missed anything - and I didn't - it's exactly that query (with only the ID varying) for every query, those that work, and those that don't.</p> <p>The only thing I can think here is that there must be an issue with MySQL's DATE_ADD function. Has anyone else experienced anything like this?</p> <p>UPDATE: I should add that the joined field is correct with the current date in the cases where the expires date is incorrect.</p> <ul> <li>I'm using MySQL 5.0.81.</li> <li>There are no triggers.</li> <li>The table is using MyISAM.</li> </ul> <p>IMPORTANT UPDATE: I'm an idiot - when I say 11-30-1999 that's not actually what's in the database. I absent-mindedly wrote that, but in fact the database contains the value 00-00-0000 - 11-30-1999 is just how it gets rendered by PHP onto my page. Sorry about that, hopefully that will make this problem less difficult to figure out.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload