views:

174

answers:

1

I have a record of data with unix time date in it

i want to select the row based on the date/month/year only (not with time)

currently Im using something like this

select * 
  from tablename 
 where date > '$today' 
   and date < '$tomorow' 
 LIMIT 1; 

how ever this is not that accurate if the $today and $tomorrow have different time (but same date)

is there any better way to do this?

+1  A: 
... WHERE DATE(FROM_UNIXTIME(date)) > DATE(FROM_UNIXTIME('$today')) ...

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

Amber
This would cause the query to use a table scan, which may not be desirable if the table is very large.
BipedalShark
Good point. Probably not the most optimal solution.
Amber