Jump to content

NOW()


jmaccs64

Recommended Posts

I think fenway is just pointing out that the mysql date functions will do some strange things when dealing with invalid dates, and this isn't necessarily documented.  I've done a lot of looking at mysql date handling and what I found is that mysql comes in a mode where it will accept invalid dates in many cases.  This is actually by design, and can be reconfigured in the latest version of mysql.  For example, you can store a datetime that has zeros in it, or a valid year and invalid month/day or any variation.  You can now change the configuration of mysql so that it does not allow invalid dates, but that is not the default, nor have I personally played with the setting.

 

In this particular case, the point is moot, because the parameter NOW() will always be valid.  One other thing about DATE_SUB, is that it is fairly new function, whereas DATE_ADD has been available for a long time.  You can achieve the same effect with DATE_ADD by passing negative interval values ie. (INTERVAL -30 SECOND), and I always use DATE_ADD for that reason.

 

In conclusion: the OP has not been seen in this thread for a while.  I never got an answer on whether or not the column in question is a datetime, an integer or a mysql timestamp.  That is an important piece of information.  Regardless, he seems no longer to care about this thread, so let's let it go off to sleep.

Link to comment
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.