Thanks to anyone who may be able to help with this question.
I currently store dates in my database using varchar so that it looks like 12/04/2005 (I know, I should be using date or timestamp but the database is large so I want to do this as a last resort). I want to be able to display records from the database based on dates that the user selects. For instance, if a user choosing a beginning date of 01/01/2004 and an end date of 01/01/2005, the php should display all records between those dates.
My initial thought is to use unix timestamp and run a query something like this:
SELECT * FROM my_database WHERE date >= 'strtotime($GET['startdate'])' AND date <= 'strtotime($GET['enddate'])' ORDER BY date ASC"
where strtotime () converts the dates to a timestamp. The problem that I encounter is that I also need to convert 'date' to a unix timestamp. I get an error when I try:
SELECT * FROM my_database WHERE strtotime(date) >= 'strtotime($GET['startdate'])' AND strtotime(date) <= 'strtotime($GET['enddate'])' ORDER BY date ASC"
and nothing happens when I try:
SELECT * FROM my_database WHERE 'strtotime(date)' >= 'strtotime($GET['startdate'])' AND 'strtotime(date)' <= 'strtotime($GET['enddate'])' ORDER BY date ASC"
Any help would be greatly appreciated.
Thank you,
Justin