mysql日期比较

时间:2011-02-02 15:51:13

标签: mysql

在我的一个mysql表中,我有start stop列。 例如,start的值为2011-01-21,stop的值为2011-03-23。 假设今天2011-03-10如何确定“今天”是在开始和停止期间之间?

3 个答案:

答案 0 :(得分:5)

select * from mytable where CURDATE() between start and stop 

答案 1 :(得分:0)

select
    *
from
   `tbl`
where
   now() between `the_start_date` and `the_end_date`

答案 2 :(得分:0)

嗯有点模棱两可,但你今天可以将日期存储在一个变量中并执行“select start,stop from table”然后在PHP for循环中你可以评估你今天的变量是否在两个日期值之间?

相关问题