SQL statement for PHP articles to be archived by date (month and day)

WBOY
Release: 2016-07-25 09:03:51
Original
1136 people have browsed it
  1. select FROM_UNIXTIME(pubtime, '%Y-%m') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m')
Copy code

PHP articles archived by date (day) SQL

  1. select FROM_UNIXTIME(pubtime, '%Y-%m-%d') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m-%d')
Copy code

Non-timestamp date format archive (date_format formatted date)

  1. select date_format(`post_date`,'%Y%m%d') as pubtime, count(*) as cnt from wp_posts where `post_status`='publish' group by date_format( `post_date`,'%Y%m%d') order by `ID` desc

  2. select date_format(`post_date`,'%Y%m%d') as pubtime,date_format(` post_date`,'%m month %d day') as shijian,count(*) as cnt from wp_posts where `post_status`='publish' group by date_format(`post_date`,'%Y%m%d') order by `ID` desc limit 0,7

Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template