Jump to content

last 7 days stats


Leverkusen
Go to solution Solved by Barand,

Recommended Posts

a part of a code where is showind me the yesterday's results, how i can change that to last 7 days results?

if($_GET['id']==""){
	$result = mysql_query("select *,
		(select count(*) from clanovi_njihovi_parovi where status = 1 and racun=r.id and datum=curdate()-1) pog_pre,
		(select count(*) from clanovi_njihovi_parovi where status = 0 and racun=r.id and datum=curdate()-1) 
promaseno_pre,
		(select avg(kvota) from clanovi_njihovi_parovi where status =0 and racun=r.id) prosjek_l
		from clanovi_njihovi_racuni r order by profit desc,id");
Link to comment
Share on other sites

$dt = new DateTime('now');
$qry = "select count(*) from clanovi_njihovi_parovi where status = 1 and racun=r.id
and datum BETWEEN '{$dt->format('Y-m-d')}' AND '{$dt->sub(DateInterval::createFromDateString('7 days'))->format('Y-m-d')}'";

That's off the top of my head, but should get you started - the php DateTime() docs are comprehensive. Also, I know the statement will parse in SQL Server, but unfortunately I don't use MySQL at work so the syntax might be slightly different.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.