Some explainations to the code. As I have a time series and I want to calculate hours only for March, there are 3 cases:
1. my date starts in march and goes beyond this month. So delta time is monthend(march) - startdate
2. starts before and ends in march. delta time = termination date - monthstart(march)
3. It goes over the whole march(my case), so deltatime = monthend(march) - monthstart(march)
What I expect to reach is:
How many hours should work
The main problem is that my algorithm calculates time differences for all 4 states(two states with 4, two with 3), while I need to take the minimum date by state and sum them. Hope I explained it clearly.