mlsamuelson.com

using FROM_UNIXTIME() to convert timestamps in your queries

SELECT FROM_UNIXTIME(access, '%Y %M') AS 'Year and Month', count(*)
FROM users GROUP BY FROM_UNIXTIME(access, '%Y %M') WITH ROLLUP;

Select all user's access times grouped by year and months with counts.

More info can be had at http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#func...

Thanks owed to Chandima for making me aware of this great function.

No comments

Add your comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

Find Me Around

User login