duanpei4455 2013-09-28 07:19
浏览 29
已采纳

从时间戳中选择月份

I want to fetch data according to month. Date is stored in timestamp.

select pdate,COUNT(*) from qchat_sessions WHERE month(pdate)='09'

i am using this query but thats not working correctly.

and how to echo the date from time stamp

Thanks

EDIT1

Mainly what i want to do is to echo the dates from that month with no of rows. in db i have two dates : 2013-09-27 and 2013-09-28 but using:

`$sss=mysql_query("SELECT DATE(pdate),COUNT(*) FROM qchat_sessions WHERE MONTH(pdate)='09'"); $rows = mysql_fetch_array($sss); $a = array($rows[0],$rows[1]);

foreach ($a as $b)

{

print $b . " ";

It echos only 1 date may be i am missing something. } `

  • 写回答

2条回答 默认 最新

  • dongxiong5546 2013-09-28 07:43
    关注
    SELECT DATE(pdate) as pdate,COUNT(*) 
    FROM qchat_sessions 
    WHERE MONTH(pdate)='10';
    

    EDIT

    SELECT DATE(pdate) as pdate,COUNT(*) 
    FROM qchat_sessions 
    WHERE MONTH(pdate)='10'
    GROUP BY DATE(pdate);
    

    EDIT

    You can use this code printing the data. Edit as your wish

    while ($row = mysql_fetch_array($sss)) {
        echo $row[0];
        echo $row[1];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用