Monday, December 12, 2011

How can I change this select statement to pull information from start date to an end date?

I only want to get the records from a date range using the variables session_start_date and session_end_date. Those variable are input by the user as a text value. Do I need to convert it to a date type?


Here is the select statement I need to alter:


$query = "SELECT session_id, title, DATE_ADD(scheduled_time, INTERVAL $time_diff HOUR), teacher, DATE_ADD(time_started, INTERVAL $time_diff HOUR), DATE_ADD(time_finished, INTERVAL $time_diff HOUR) from session where session_id=$session_id";|||make variables for the start_date and end_date. Assign values to those variables. Lastly append your statement AND (datefieldfromyourdb %26gt;= start_date AND datefieldfromyourdb %26lt;= stop_date)

No comments:

Post a Comment