表A, ID        startdate
-----------------------------------
1        1213459200
2        1213632000
3        1213459200
4        1213632000
5        1213459200
6        1213632000
取出某年某月的记录,比如2009年5月的所在记录,或者其它年月月的。

解决方案 »

  1.   

    string date ( string format [, int timestamp] )
    date("Ymd",$startdate);
    可以从数据库中先把时间数据读出来用date("Ymd",$startdate)转换成正常的时间格式,然后再比较。
      

  2.   

    select * from Table where startdate between UNIX_TIMESTAMP(2009-5-1) and UNIX_TIMESTAMP(2009-5-30)
      

  3.   


    select * from Table where startdate between UNIX_TIMESTAMP('2009-5-1 00:00:00') and UNIX_TIMESTAMP('2009-5-30 00:00:00')
    //2楼正解,但还是有点不完美,修改一下,也可以用dateformat格式化日期,然后substr,这样很麻烦,所以建议楼主还是使用2楼的方法吧
      

  4.   

    MYSQL还是瞒好用的  呵呵
      

  5.   

    嗯~楼上的可以了
    开始结束时间可以在pgp计算
      

  6.   

    select * from a where from_unixtime(startdate,'%Y%m')='200805';