我的問題是比較<=
和>=
之間的記錄 我的表包含列ID,名稱,地址,堆棧,StartDateTime,EndDateTime。 我想獲取StartDateTime
和EndDateTime
之間的記錄。 日期時間格式是0000-00-00 00:00:00
使用mysql比較小於或大於記錄之間的記錄
mysql-> Select * from Table_nm where StartDateTime>= $DATETIME and EndDateTime<= $DATETIME1;
所以,我的問題是如何比較的是,
1. $DATETIME= 2015-02-03 10:00:00 and $DATETIME1 =2015-02-06 20:00:00
2. $DATETIME= 2015-02-03 05:00:00 and $DATETIME1 =2015-02-06 13:00:00
3. $DATETIME= 2015-02-03 10:00:00 and $DATETIME1 =2015-02-06 11:00:00
喜歡聰明的記錄包含日期時間, 這樣的記錄,給我結果如下圖所示過濾器。
1.If I want to filter record where StartDateTime>=2015-02-03 00:00:00 and EndDateTime<= 2015-02-06 00:00:00.
2.If I want to filter record where StartDateTime>=2015-02-03 09:00:00 and EndDateTime<= 2015-02-06 12:00:00.
3.If I want to filter record where StartDateTime>=2015-02-03 01:00:00 and EndDateTime<= 2015-02-06 22:00:00.
和如何該過濾器爲日期時間>=
和<=
作品,請幫幫忙!
告訴我你的結果,以及是什麼結果,當你運行上面的查詢 – Asif 2015-02-23 13:02:15
是這會工作,如果確實有行滿足這種條件 – Ghost 2015-02-23 13:02:24
是的它的工作原理,但我想如何比較後端在MySQL中。我想搜索見(2號)記錄。那時它只顯示這個時間範圍之間的時間範圍?並查看f(1號)記錄。我搜索它的時間12到12是顯示所有記錄之間還是僅顯示誰的時間是'='到00:00:00 – Pratiksha 2015-02-23 13:06:09