在MySQL中显示从now()到接下来的7天的记录 [英] Show records from now() till next 7 days in mysql

查看:125
本文介绍了在MySQL中显示从now()到接下来的7天的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从现在的日期时间中选择行,直到将来的7天,我该怎么做? 阅读了大量有关mysql的日期函数的信息,但无法弄清楚,这是MySQL代码:

I want to select rows from the datetime now till 7 days in the future, how can I do this? Read alot about the date function of mysql but cant figure it out, this is the MySQL code:

SELECT  id, date_format(datum, '%d/%m') AS date,
        date_format(datum, '%H:%i') AS time, date  
FROM wedstrijden
WHERE date >= now()
ORDER BY datum asc 

我必须采取以下行动:

date >= now() till 7 days further

推荐答案

我认为最优雅的方法是:

I would submit that the most elegant way would be:

WHERE `date` BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 7 DAY)

此文档页面就像有史以来最有用的东西.给它加上书签,因为它非常方便.

this doc page is like the most useful thing ever. Bookmark it, because it is totally handy.

这篇关于在MySQL中显示从now()到接下来的7天的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆