1

我想获得未来 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 中工作......谢谢......我正在尝试的其他方式是

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
4

5 回答 5

0

此查询可能会为您提供输出:

  SELECT * FROM tbl_name WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY)

让我知道解决方案

谢谢

于 2012-11-23T08:16:26.823 回答
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
于 2012-11-23T08:16:34.887 回答
0

像下面这样的东西应该会有所帮助

SELECT * FROM `imdb` WHERE ( DATE_SUB(`release`, INTERVAL 2 MONTH) < now()) ORDER BY STR_TO_DATE(`release`, '%e %M %Y') DESC LIMIT 20
于 2012-11-23T08:17:29.147 回答
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";

希望它对你有用!

于 2012-11-23T08:25:17.057 回答
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"

这样我就可以限制开始和结束日期......从现在开始()......希望会有所帮助

于 2012-11-23T08:31:39.160 回答