lets say that a user want to take vacation from 17-10-2010 to 15-11-2010.
on some setup page i declared start date and end date for each month as following:
m1 :from 1-10-2010 to 20-10-2010 m2: from 21-10-2010 to 10-11-2010 m3: from 11-11-2010 tom 30-11-2010
as we can see,the vacation related to many periods(m1,m2,m3) not to only one period, so i need to divide the vacation into periods, and The array of periods should look like this:
from 17-10-2010 to 20-10-2010 from 21-10-2010 to 10-11-2010 from 11-11-2010 to 15-11-2010
i think that solving the problem with only using PHP will be complex,so i want to use PHP and MySQL functions to solve the problem,
Any help please?
SELECT GREATEST(period_start, @vacation_start), LEAST(period_end, @vacation_end) FROM mytable WHERE period_start <= @vacation_end AND period_end >= @vacation_start
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki