James Bensley wrote:
SELECT blah, blah, blah FROM tblBlah WHERE date_entered BETWEEN '01/01/2010' AND '20/01/2010'
This will select records from my table who's date_entered field is from 01/01/2010 and 19/01/2010. This is because the BETWEEN command seems to go UP TO the day specified but not inclusive.
So I thought I would just add +1 on to the data submitted from the PHP search page which works just great except for when you put 31 in as the day of the month, (so say we search from 01/01/2010 to 31/01/2010) it makes it into 32 and the querie returns 0 rows. However if I add an IF statement to not increment the day value by 1 if "31" is given as the last day in the query, we then only get results for 01/01/2010 to 30/01/2010.
A quick look at the docs suggests that you could try
SELECT blah, blah, blah FROM tblBlah WHERE date_entered BETWEEN '2010-01-01' AND ADDDATE('2010-01-19', 1)
- in this form, adddate assumes days as the second argument.
Have a scope at http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function...
Simon