I have a table with the following structure
leave_id int(10) No
user_id int(10) No
leavetype_id int(15) No
fromdt date No
todt date No
no_of_days varchar(10) No
status enum('0', '1', '2', '3') No
modifier varchar(35) No
modifiedby varchar(25) No
description varchar(100)
which contains data like this
leave_id 194
user_id 2
leavetype_id 2
fromdt 2011-04-26
todt 2011-05-09
no_of_days 9
status 3
modifier
modifiedby
description some description
Now I need to search based on the leave date. For eg I want to see the leaves a user taken f( for eg user_id = 2) between 2011-04-27 and 2011-05-08. As you can see, as per the result posted above the user_id 2 was on leave from 2011-04-26 to 2011-05-09. And the given date 2011-04-27 and 2011-05-08 comes between that.
I have tried the following things
- Between AND
- Less than Greater than
The following will show any leave that has at least 1 day in common with the period between
'2011-04-27'and'2011-05-08':This will show the leaves that spanned the whole period
'2011-04-27'to'2011-05-08':