-3

Is there any way to find all records in MySql Query between 2 dates where we want to increment 2nd date by 1.

Suppose user inputs Date1 as 2017-04-01 and Date2 as 2017-04-25 but here I always want to take Date2 after incrementing it by 1 Day i.e. Date2 as 2017-04-26 here.

Please let me know if possible?

Amit Gupta
  • 2,771
  • 2
  • 17
  • 31
  • check this https://stackoverflow.com/questions/8904597/how-to-check-if-a-date-is-between-date1-and-date2-using-mysql?rq=1 – manvi77 Apr 29 '17 at 06:33
  • @Abi: regarding the use of inline code formatting in your suggested edit, please only use that on code or console I/O. – halfer Apr 29 '17 at 11:10

1 Answers1

1

You can use MySQL's DATE_ADD() function to add one day to the upper date in your range:

SELECT *
FROM yourTable
WHERE date BETWEEN '2017-04-01' AND DATE_ADD('2017-04-25', INTERVAL 1 DAY) 
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360