hi i am trying to get nearest Date here is my code
SELECT schedule_date FROM schedule_table WHERE schedule_date > '2012-06-07' and event_id='23' ORDER BY schedule_date ASC
LIMIT 1
here actual table schedule_date contain 2012-06-07 00:00:00 like this.But i Check ‘2012-06-07’ so
i get output like this 2012-06-07 06:53:57 that mean same date came but i need 2012-06-08 04:53:57
i think here we need to check this condition using like operator
how could i use like operator in this query to get closest date in sql.
Thanks for advance.
You have a classic case of matching date value with a datetime field type. What you need is the earliest time value within the same date. Possibly your data contains multiple rows with data on same date but different time values. You should use the following:
The date() function is explained in MySQL documentation here.