我想获得未来2个月内我将使用以下查询的结果(发布日期格式在数据库中是正常的 2013年3月8日)
SELECT * FROM imdb WHERE (STR_TO_DATE(`release`, '%e %M %Y')-now()<2months) ORDER BY STR_TO_DATE(`release`, '%e %M %Y') DESC LIMIT 20
我知道2个月不会工作......所以这将如何在mysql ... thx ...我尝试的其他方式是
SELECT * FROM imdb WHERE (STR_TO_DATE(`release`, '%e %M %Y')-now()<5184000000) ORDER BY STR_TO_DATE(`release`, '%e %M %Y') DESC LIMIT 20
答案 0 :(得分:0)
此查询可能为您提供输出:
SELECT * FROM tbl_name WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY)
让我知道解决方案
由于
答案 1 :(得分:0)
试试这个::
SELECT * FROM imdb WHERE DATE_SUB(CURRDATE(),(STR_TO_DATE(`release`, '%e %M %Y')) <60 ORDER BY STR_TO_DATE(`release`, '%e %M %Y') DESC LIMIT 20
答案 2 :(得分:0)
以下内容应该有所帮助
SELECT * FROM `imdb` WHERE ( DATE_SUB(`release`, INTERVAL 2 MONTH) < now()) ORDER BY STR_TO_DATE(`release`, '%e %M %Y') DESC LIMIT 20
答案 3 :(得分:0)
$sql = "SELECT * FROM tableName ( SELECT MONTH(datefieldName) AS m , DAY(datefiled) As d FROM tableName) AS tmp ORDER BY (m,d) < ( MONTH(CURDATE()), DAY(CURDATE()) ), m , d limit 0,20";
希望它对你有用!
答案 4 :(得分:0)
thx伙计们我找到了ans(先生ji帮助了我;))
"SELECT * FROM imdb WHERE (TO_DAYS(STR_TO_DATE(`release`, '%e %M %Y'))-TO_DAYS(NOW())<60 && TO_DAYS(STR_TO_DATE(`release`, '%e %M %Y'))-TO_DAYS(NOW())>0) ORDER BY STR_TO_DATE(`release`, '%e %M %Y') LIMIT 20"
这样我就可以限制开始和结束日期...从现在开始()希望能帮助