Skip to content
Advertisement

Check one data lies within range of two date field in mysql

I have this data:

enter image description here

And, I am trying to compare that one of the date is within range of the given data, but without any success. Here is my query:

The type of both column is set to date.

Update:

Advertisement

Answer

Your are using wrong logic here. As per your requirement, your input date value should fall BETWEEN the leave_start_date and leave_end_date. So , switch your logic to other way around:


One can also write this query using >= and <= operators. Conceptually, the input date value should be greater than or equal to the leave_start_date. Also, for it to fall within the define range, it should be less than or equal to the leave_end_date:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement