sql基于时间查询(select)


返回所有posts表中,2009年5月13号到16号的记录。created是posts表的timestamp。

select * from posts where date(created) bettwen date(2009-05-13) and date(2009-05-16)

除了date(),还有year(),month(),day()可以使用。year(2009-05-13) 返回2009,month(2009-05-13)返回05,day(2009-05-13)返回13

Happy Coding…

  1. #1 by Mr WordPress on May 15, 2009 - 4:18 am

    Hi, this is a comment.
    To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.

  2. #2 by Alicia on May 17, 2009 - 2:38 am

    Upup :)

(will not be published)