Demaestro

msg:4168722 | 6:49 pm on Jul 12, 2010 (gmt 0) |
It depends. Are you storing the dates that a record is entered on? If yes, in what data type? DATE, DATETIME, STRING?
|
rocknbil

msg:4168857 | 12:35 am on Jul 13, 2010 (gmt 0) |
^ ^ That would be important. :-) If it's a datetime (or timestamp) field, use now() instead of curdate(), but for date format, if you want to include today, select * from table where datefield >= date_sub(curdate(), interval 6 day) and datefield <= curdate(); If you want the previous 7 days NOT including today, select * from table where datefield >= date_sub(curdate(), interval 7 day) and datefield < curdate(); If it's varchar, you have a problem and it has to be done in your programming.
|
phex

msg:4169404 | 6:58 pm on Jul 13, 2010 (gmt 0) |
Demaestro Yes i am storing the dates and the field is time and its data type is timestamp.
|
Demaestro

msg:4169409 | 7:04 pm on Jul 13, 2010 (gmt 0) |
This should be what you need then select * from table where datefield >= date_sub(curdate(), interval 6 day) and datefield <= curdate();
|
youngflower

msg:4169860 | 8:30 am on Jul 14, 2010 (gmt 0) |
Sorry, I cannot solve your problem.
|
phex

msg:4170942 | 6:34 pm on Jul 15, 2010 (gmt 0) |
thanks a lot guys for the code. The now() does it for me, i appreciate.
|
|