Database statistics, submissions over last 12 hours

From: Date: Wed, 09 Jan 2002 10:08:49 +0000
Subject: Database statistics, submissions over last 12 hours
Groups: php.db 
Request: Send a blank email to php-db+get-15579@lists.php.net to get a copy of this message
Hi, I have a database containing a field of type datetime (0000-00-00 00:00:00). The datetime field of each new record is set to the current date and time when a new record is added. I would like to be able to produce some statistics on the new records entered within the past 12 hours. I would like to produce an array of 12 values, each value representing the number of records with a timedate value within that hour. I am not sure quite how to explain this properly, so I guess I'll provide an example to make it a bit clearer, say I have the following database table 'dates' as follows: id date 0 2001-12-16 13:20:51 1 2001-12-16 15:13:19 2 2001-12-16 15:43:38 3 2001-12-16 15:53:23 4 2001-12-16 16:16:31 5 2001-12-16 16:31:52 6 2001-12-16 17:28:06 7 2001-12-16 18:06:41 8 2001-12-16 21:08:30 9 2001-12-16 21:15:01 and so if the current time was 21:18 when the script was run, I would like it to output an array with values as follows {0,0,0,1,0,3,2,1,1,0,0,2} I hope this makes a bit of sense to someone who might be able to help me. Richard

« previous php.db (#15579) next »