Robert Granlund
asked on
MySQL Query WHERE MONTH
I am trying to create a query that SELECTS data out of a DB the has a date equal to the current month. The following query fails at: WHERE MONTH('date') = MONTH(CURDATE()) AND
$sql->query("SELECT doctor_doctor.doctor_id, doctor_doctor.first_name AS first_name, doctor_doctor.last_name AS last_name, doctor_schedule.doctor_id, doctor_schedule.schedule_date AS date, doctor_schedule.time AS time, doctor_schedule.location_id
FROM doctor_doctor, doctor_schedule
WHERE MONTH('date') = MONTH(CURDATE()) AND doctor_doctor.doctor='1' AND doctor_doctor.doctor_id=doctor_schedule.doctor_id AND doctor_schedule.location_id='1'
ORDER BY date DESC");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can do:
WHERE MONTH(doctor_schedule.sche dule_date) = MONTH(CURDATE()) + 1
Not sure if that's what you're asking
WHERE MONTH(doctor_schedule.sche
Not sure if that's what you're asking
ASKER
The query shows the current month but Id like to incorporate a "Next Month" and Prev Month" Button but I'm not sure were to start
Next month would be
WHERE MONTH(doctor_schedule.sche dule_date) = MONTH(CURDATE()) + 1
prev month
WHERE MONTH(doctor_schedule.sche dule_date) = MONTH(CURDATE()) - 1
WHERE MONTH(doctor_schedule.sche
prev month
WHERE MONTH(doctor_schedule.sche
ASKER