Forum Moderators: coopster
How would I get data for the previous week without having to specify it? For example, the following wouldn't work:
$enddate=date(Ymd);
$startdate=date(Ymd)-6;
SELECT data FROM table WHERE date BETWEEN '$startdate' AND '$enddate'
I want $startdate to be equal to 2006-05-26. Is this possible?
$temp_last_week = mktime(0,0,0,date("m"),date("d")-7,date("Y"))
OR
$temp_last_week = $temp_today - 604800 (which is 86400x7) (86400 is the seconds per day(24h))
$last_week = date("m-d-Y",$temp_last_week);
Hope this helps
SELECT
data
FROM table
WHERE date BETWEEN CURRENT_DATE - INTERVAL 6 DAY AND CURRENT_DATE
;
Note that if you truly are using
dateas a column name you may want to reconsider as it is a reserved word in most relational database management systems.