Really simple Date Question!
Posted: Tue Jun 21, 2011 3:30 pm
For the life of me I can't remember how to structure this. Please someone rescue me from my insanity!
I am trying to php code a sql script that retrieves the last 7 days of data. I have two dates, $startDate and $endDate like ths:
I have a sql script like this:
But this does not work! I get a blank page where I should get results. Please can someone tell me where I am going wrong?!
Thanks
Peter
I am trying to php code a sql script that retrieves the last 7 days of data. I have two dates, $startDate and $endDate like ths:
Code: Select all
$startDate=date('Y-M-D', strtotime('-1 week'));
$endDate=date('Y-M-D', strtotime('-1 day'));
Code: Select all
$query = "select account as account,
campaign as campaign,
sum(impressions)impressions,sum(clicks)clicks,sum(cost)cost,avg(avg_position),sum(conv_mpc)conversions
From ppc_data
where date between '".$startDate."' and '".$endDate."'
group by campaign
order by conversions desc;
";
Thanks
Peter