|
Posted by NC on 02/16/06 06:40
rjfjohn...@hotmail.com wrote:
>
> Today is Thursday 16-Feb-06. The same thursday last year is 17-Feb-05.
> Because I am comparing daily sales between years, I need to know the
> date of the same weekdayname as last year, so that I am comparing
> Saturdays with Saturdays, Sundays with Sundays, etc
Essentially, you need to know the date that was 52 weeks before today:
$today = time();
$year_ago = $today - 52*7*24*60*60;
$today_date = date('Y-m-d', $today);
$year_ago_date = date('Y-m-d', $year_ago);
Now you can use $today_date and $year_ago_date in a query...
Cheers,
NC
[Back to original message]
|