Re: PHP querying mysql db for data limited to the last month

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Vinny Gullotta wrote:

> So I have this code I'm working with (pasted below) that queries a
> mysql db table called timetracking. The goal of the page is to search
> the db for all data based on a certain engineer, sorted by product and
> it takes pre-defined values based on actions performed, sums them
> based on product and display's the percentage of time an engineer has
> spent on each product. Everything works great except I need to limit
> the results to the last months data only, but everything I try seems
> to just break it. Can anyone push me in the right direction a little?

I can't see a timestamp field in your code, but I'm assuming you've got
one? 

SELECT *,SUM(timespent) FROM timetracking 
WHERE engineer=<engineer> AND
month(timestamp)=month(date_sub(now(),interval 1 month))
GROUP BY product;


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux