View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 11:29 AM
Summercool
 
Posts: n/a
Default getting records for 1 day

in SQL, i wonder if I do a


select * from tablefoo where add_date = "2007-11-01"


then it may not show any record as it will only match recorded added
exactly at 2007-11-01 00:00:00
so to limit that day, I could use

select * from tablefoo where date(add_date) = "2007-11-01"

except I think if the table has millions of records, then it can take
forever to run, as it will go through all records and apply the date
function on each record's add_date.

so the following

select * from tablefoo where add_date >= "2007-11-01" and add_date <
"2007-11-02"

should work... except it is quite verbose... i wonder if there is a
better way?

Reply With Quote