MySQL GROUP BY UNIX TIMESTAMP

I’m trying to fetch a number of rows from a MySQL database and group them by the day they were posted.

End result I would like the following..

Monday
-Article 1
-Article 2
-Article 3

Tuesday
-Article 1
-Article 2

Wednesday
-Article 1
-Article 2
-Article 3
-Article 4

And so on, I’m not sure if this can be done in MySQL alone without PHP doing extra work.

This is the query I have so far but doesn’t seem to group by day.

SELECT
cms_news.news_id,
cms_news.news_title,
cms_news.news_date,
cms_news.news_category,
cms_news.news_source,
cms_news.news_type,
cms_news.news_content
FROM
cms_news cms_news,
GROUP BY
DAYOFMONTH(FROM_UNIXTIME(cms_news.news_date))
ORDER BY
cms_news.news_date DESC

Thanks.

Incoming search terms:

  • how to run aggregate function in php in codeigniter
  • mysql regrouper timestamp par jour
  • python group by timestamp
  • unix timestamp mysql

Related posts:

  1. Unix timestamp VS datetime I have a Mysql table, which has a column add_date. It tracks the date/time when...
  2. CakePHP: No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) I have had a cakephp app running fine on my local machine (mac osx) for...
  3. Why do PHP and MySQL unix timestamps diverge on 1983-10-29? I’ve been using PHP’s strtotime and MySQL’s UNIX_TIMESTAMP functions in my app, to convert dates...
  4. UNIX timestamp always in GMT? UNIX timestamp always in GMT? I tried to run php function time() and when I...
  5. How do I add 24 hours to a unix timestamp in php? I would like to add 24 hours to the timestamp for now. How do I...
  6. Check whether the string is a unix timestamp I have a string and I need to find out whether it is a unix...
  7. Compare group of tags to find similarity/score with PHP/MySQL My Question is, how do I compare a group of tags to another posts tags...
  8. How do I manage development and deployment of my website as part of a group? I’ve been reading this site here and there and appears as though you guys have...
  9. Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in I’m trying to connect to my MySQL DB with the Terminal on my Apple (With...
  10. How many MySQL queries should I limit myself to on a page? PHP / MySQL Okay, so im sure plenty of you have built crazy database intensive pages… I am...

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

One Response to MySQL GROUP BY UNIX TIMESTAMP

  1. Narcis Radu says:

    0

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>