Don't worry, it's easier than you think. when you get date/time from user, make sure to convert the format on it to be the same as your database, and then your query would just be:
Code: Select all
$sql = "SELECT fields FROM table WHERE datefield BETWEEN ".$_POST['start_date']." AND ".$_POST['end_date']
depending on your date format in the database you may need to add single quotes around the date values in the where field.
once you've gotten your result set, to send it to excel, just output your headers and then field values to a file separated by commas. save with extension of .xls and any version of excel should have no problem opening it.