I want to create a dynamic, generic function that will SELECT data from a mysql table based on various types of dates.
The dates could be in the form of:
- No date
- A specific date
- A date range
- x many months from the current date
i.e. mysql statement - WHERE EXTRACT(YEAR_MONTH FROM date) = EXTRACT(YEAR_MONTH FROM DATE_SUB(NOW(), INTERVAL x MONTH))
- etc -- whatever other variations
Anyone have any suggestions on the best way of accomplishing this?