How do I query for data that falls between two dates?
I have an html form to select two dates 开发者_高级运维from dropdown. Now I need to retrieve all records from a MySQL database which lie between those dates. Can anyone help me?
Provided that $startDate and $endDate are in YYYY-MM-DD format (and $startDate is date before $endDate), you would probably need a query like :
$sql = "select field1, field2, ... from yourtable where yourdatefield between $startDate and $endDate";
精彩评论