Welcome to WebmasterWorld Guest from 54.159.19.75

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

mysql query with date search

     
7:47 pm on Jan 6, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Aug 7, 2008
posts: 93
votes: 0


I have a table which has dates for events.
the mysql column type is datetime

Now I have a calendar which returns date only (not time)
and I have full date and time both in mysql records.

So I want to run the query so it searches for all the events in that specific date?

please advise.

thanks in advance.
8:13 pm on Jan 6, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:May 8, 2008
posts: 74
votes: 0


Readable way:

DATE(event_date)=?


Optimized way (if you have millions of records):

where event_date > "$date 00:00:00" and event_date <= "$date 23:59:59"
8:25 pm on Jan 6, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Aug 7, 2008
posts: 93
votes: 0


Hi,

thanks very much for helping. Yes, I already tried with DATE() and it worked perfectly fine.

Thanks again for your help.