phpmysql

Add days to a date php object and then verify if it is between 2 date objects


In my fitness system, i have to show some general status on the index page.
I have the date when the user was added to the database, the actual date, and the actual date plus 15 days.

So i have to verify if the added user date is between the actual date and the actual date plus 15 days.
This verify must be inside the query, like.. SELECT * FROM users WHERE date (is between today and today+15 date)...

What is the best way to do that?
Thanks in advance.


Solution

  • SELECT   *
    FROM     users
    WHERE    date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 15 DAY)
    

    See the other Date Time Functions available in MySQL.