Date operations.
| From: | Garry Optland | Date: | Tue, 29 Jan 2002 08:10:25 +0000 |
| Subject: | Date operations. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-16271@lists.php.net to get a copy of this message | ||
Hi All,
I have a problem working out a suitable algorithm either in PHP or MySQL.
Basically I have a DB that keeps track of breeding records. Each record
has a paired data, and a split-up date.
I need to generate some statistics to work out average numbers of pairs
per month, averaged on a daily basis, for a given start and stop date,
typically a year or year-to-date.
All the algorithms I can think of are messy, where I have to loop through
all the breeding records for every day of the year, and count how many
pairs are breeding by seeing if the date is between the start and stop
dates, and then average that on a monthly basis. I can't see
that scaling very well, as there might be several hundred breeding records
for a given year, multiplied by 365 days.
Has anyone any hints/pointers for an efficient way to do this?
Regards,
Garry.