Audunfr Audunfr -5 years ago 93
MySQL Question

Query from to date with php in mysql

I have a date field in a mysql table formatted like this: Y-m-d.

I want to export every post that has a date between $fromDate and all the way to $toDate
I am sure its easy but now i am totaly blocked from ideas.

I am using codeigniter if that helps.

Best Regards

Answer Source

Try building a query similar to this and passing it to mysql_query (assuming your date format in $fromDate and $toDate match the date format of your mysql column)


$query="SELECT * FROM table WHERE date BETWEEN '$fromDate' AND '$toDate'";

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download