Wednesday, July 13, 2011

MySQL Date Range Query

Here is an example to query MySQL Date Range given the date field is of
type TimeStamp. The date_format() will remove the time part in comparing.
1:  select date_format(date_purchased,'%m/%d/%Y')as dates, url   
2:   from dbCommerce.tblproducts   
3:    where date_format(date_purchased,'%m/%d/%Y')  
4:       between '04/30/2011' and '05/30/2011'  
5:           order by date_purchased asc;  


Post a Comment