Overlapping Days Daniel Nicolalde  2011-11-09 13:03
Status: Closed
 
Hi Ben,

Thank you for the help, the table is working. I am now trying to calculate the exact number of days two project assignments overlap. I am separating into four categories:
1. Projects that started before and go beyond the time interval of interest
2. Projects that start before and finish with the time interval
3. Projects that started within the time interval and finish during the time interval
4. Project that start during the time interval and finish after the time interval.

For the first option I am using the following CASE, some project don't have endate therefore I am using curdate to set those dates:

CASE
WHEN ((CAST (h.date AS DATE) < CAST(StartDate as DATE)) AND (CAST (COALESCE(curdate(), h.enddate) AS DATE) > CAST(EndDate AS DATE)))

The problem is that it display almost all the alternatives but in some case it displays it adds time intervals that do not adhere to this statement, I am looking for project in 2007 and it show more than two projects that started before 2007 and finish in 2007.

Is there a bug in the way CASE is handle by LabKey or I am having a typo in my statement?

Thank you

Daniel