I want to get the data which the date is next 2 days from today below are my sql statement, i am using mysql
我想从今天下面2天获取日期是下面的数据是我的sql语句,我使用的是mysql
SELECT *
FROM guest g inner join reservation r on g.nric = r.guestNric
WHERE arrivalDate = DATE_ADD(NOW(), INTERVAL +2 DAY)
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?
我现在的问题是如果我正在使用=因为我的arrivalDate格式是'yyyy-MM-dd'然后Date_Add格式带有时间戳,所以它不等于任何想法我怎么能解决这个问题?
2 个解决方案
#1
2
Try this:
SELECT *
FROM guest g inner join reservation r on g.nric = r.guestNric
WHERE arrivalDate = DATE(DATE_ADD(NOW(), INTERVAL +2 DAY))
#2
0
Try replacing NOW()
with CURTIME()
. The type return value of DATE_ADD() corresponds to the type of the first parameter.
尝试用CURTIME()替换NOW()。 DATE_ADD()的类型返回值对应于第一个参数的类型。
#1
2
Try this:
SELECT *
FROM guest g inner join reservation r on g.nric = r.guestNric
WHERE arrivalDate = DATE(DATE_ADD(NOW(), INTERVAL +2 DAY))
#2
0
Try replacing NOW()
with CURTIME()
. The type return value of DATE_ADD() corresponds to the type of the first parameter.
尝试用CURTIME()替换NOW()。 DATE_ADD()的类型返回值对应于第一个参数的类型。