On 24 February 2010 15:13, James Bensley jwbensley@gmail.com 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.
...
How can I combat this or is there a "proper" way of doing this as mine almost defiantly isn't going to be the best method?
Well, in addition to the other solution mention, the correct way to add to dates is typically database dependent. For example, you could do in MySQL ...
SELECT blah, blah, blah FROM tblBlah WHERE date_entered BETWEEN '01/01/2010' AND DATEADD('d', 1, '20/01/2010')
which would get around your "32 day in month" problem.
Greg