Hi ,
I've been trying to get this sorted for ages and have searched loads of forums and so on ... no joy !
Basically I have a DB setup with a timestamp filed and date filed
timestamp = time();
date = date('d-m-Y' , time());
This is working fine and inputting the timestamp and also the date into my DB, I have a seach function on the date where the user selects a date from a calendar ie 05-05-2006 and that search the date colum, then I have the ability to seach back 7 days using the time() - 60*60 etc ....
My problem is searching between dates !!! When the user inputs 01-04-2006 to 01-05-2006 and using the sql command WHERE date >= $date1 AND date <= $date2 it doesnt work, and I have no idea how to make it work - i've tried converting the 01-04-2006 to a timestamp but no luck either and it tries to find the exact match even using LIKE its not getting it.
Can anyone help me with this - I hope what I'm saying makes sence lol
Thanks
Wayne
Help using dates to search !
Moderator: General Moderators
You will need to convert the dates to timestamps in order to do what you want (as you tried, but did something wrong
). Have a look into the mktime() function.
However, you might want to look into using MySQL's date functions, as that are what they are there for
.
However, you might want to look into using MySQL's date functions, as that are what they are there for