I need to check if the current time is within a certain range of fields within the DB.
For example in the DB I would store a start time, end time, start date, and end date.
I then need to check if the current date is within the rage of values returned by the query.
I have attempted:
WHERE start_date <= $currdate
AND end_date >= $currdate
AND start_time <= $currtime
AND end_time >= $currtime
Which works great, until we get a situation where the dates overlap two days, in which case the query returns NULL as end_time is obviously LESS than the current time.
I guess I need a way to combine start_date and start_time with end_date and end_time?
Have you tried timestamp()?
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_timestamp
Perhaps can do something like
This is assuming, of course, that your start/end date and time are related. Not fully sure what the business logic is behind separating those two fields…