SQL语句从现在开始获取未来2天的日期 [英] SQL statement to get the date next 2 days from now
本文介绍了SQL语句从现在开始获取未来2天的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从今天开始获取日期为未来2天的数据,以下是我的sql语句,我正在使用mysql
I want to get the data which the date is next 2 days from today below are my sql statement, i am using mysql
SELECT *
FROM guest g inner join reservation r on g.nric = r.guestNric
WHERE arrivalDate = DATE_ADD(NOW(), INTERVAL +2 DAY)
我现在的问题是,如果我使用=因为我的arrivalDate格式为"yyyy-MM-dd",那么Date_Add格式带有时间戳,因此它不等于任何想法如何解决此问题?
My problem now is if i am using = becuase my arrivalDate format is 'yyyy-MM-dd' then the Date_Add format is come with timestamp so it wont be equals any idea how can i solve this problem?
推荐答案
尝试一下:
SELECT *
FROM guest g inner join reservation r on g.nric = r.guestNric
WHERE arrivalDate = DATE(DATE_ADD(NOW(), INTERVAL +2 DAY))
这篇关于SQL语句从现在开始获取未来2天的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文