Re: Totaling sales by month
| From: | Brian Dunning | Date: | Fri, 10 Sep 2004 23:47:44 +0000 |
| Subject: | Re: Totaling sales by month | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196373@lists.php.net to get a copy of this message | ||
Thanks Pablo - but it's more complicated than that. I'm trying to return totals for all calendar months, not all records within the past month. I'll word my question better and post it to one of your suggested lists. :)
On Sep 10, 2004, at 4:27 PM, Pablo Gosse wrote:
Brian Dunning wrote:I have a MySQL db with a datetime field containing the date and time of the sale. I want to query for a simple report that shows total sales by month. I thought this would be quick & easy but it's NOT! I can't figure out how to query for it. If this question would be better posed to a SQL list, I'd appreciate a recommendation to a good one. I couldn't find one via STFW that had any kind of volume. - BrianHaven't used MySQL in about four or five years (use PostgreSQL instead) but it will be something like this: select * from tablename where datetime_field <= (now() - interval('1 month')); The difference for you would be in the now() function (whatever mysql function returns the current system time is what you need) and the interval function. This just takes the present time and applys the specified interval. Check out http://forums.devshed.com and http://www.tek-tips.com. They have a lot of forums that are pretty heavily visited. HTH. Pablo - Brian