Jump to content

More than a month old ...


Go to solution Solved by xProteuSx,

Recommended Posts

I am extremely unfamiliar with date comparisons in MYSQL.  I've googled it, and I cannot find anything (though I am sure there must be something out there) that works for my particular situation.  Here it is:

 

I have a 'timestamp' field in my database.

 

The format of the field is like this:      2014-02-17 05:39:32

 

Now, I am trying to find all entries that are less than a month old.  Here is what I have been able to find, but have not been able to make work:

 

SELECT * FROM my_table WHERE tbl_time < date_sub(now(), interval 1 month);

 

It does not seem to matter where I have either of these:

 

SELECT * FROM my_table WHERE tbl_time < date_sub(now(), interval 1 month);

SELECT * FROM my_table WHERE tbl_time > date_sub(now(), interval 1 month);

 

Both of these queries return the same results.  How can this be?

Link to comment
https://forums.phpfreaks.com/topic/286260-more-than-a-month-old/
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.