从数据库中搜索两个日期之间的时间段获取记录
我正在尝试从mysql获取记录,该记录包含在两个日期之间的特定时间段内(这两个日期分别是date_start,date_end,并存储在两个不同的列中).
i'm trying to get records from a mysql that are included into a certain period between two dates (these two dates are respectively date_start, date_end and are stored in two different columns).
我现在在选择查询中正在做的是:
what i'm doing now in my select query is:
.. WHERE MONTH(date_start) >= '".$month_start."' and DAY(date_start) >= '".$day_start."'" AND MONTH(date_end) <= '".$month_end."' and DAY(date_end) <= '".$day_end."'"
该查询有效,但仅在某些情况下完全无效!
that query works but only in some cases, not at all!
有什么建议吗?
此处的表示例:
id_period; date_start; date_end; 27; 0000-04-02; 0000-05-31;
id_period;date_start;date_end; 27;0000-04-02;0000-05-31;
|| * id_period * || * date_start * || * date_end * || || 41 || 0000-11-01 || 0000-11-30 ||
|| *id_period* || *date_start* || *date_end* || || 41 || 0000-11-01 || 0000-11-30 ||