首頁  >  文章  >  後端開發  >  PHP文章按日期(月日)歸檔的sql語句

PHP文章按日期(月日)歸檔的sql語句

WBOY
WBOY原創
2016-07-25 09:03:511119瀏覽
  1. select FROM_UNIXTIME(pubtime, '%Y-%m') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m')
复制代码

PHP文章按日期(日)SQL归档

  1. select FROM_UNIXTIME(pubtime, '%Y-%m-%d') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m-%d')
复制代码

非时间戳日期格式归档(date_format格式化日期)

  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 月 %d 日') 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

复制代码


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn