2

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) 

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?

Adriano Carneiro
  • 57,693
  • 12
  • 90
  • 123
user236501
  • 8,538
  • 24
  • 85
  • 119

2 Answers2

3

Try this:

SELECT * 
FROM guest g inner join reservation r on g.nric = r.guestNric 
WHERE arrivalDate = DATE(DATE_ADD(NOW(), INTERVAL +2 DAY))
Hck
  • 9,087
  • 2
  • 30
  • 25
0

Try replacing NOW()with CURTIME(). The type return value of DATE_ADD() corresponds to the type of the first parameter.

Dennis Traub
  • 50,557
  • 7
  • 93
  • 108