COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: cjsasaki on 09 Dec 2015 11:22:32 AM

Title: Calculate Days between 2 dates not including Holidays?
Post by: cjsasaki on 09 Dec 2015 11:22:32 AM
Hi
How can I calculate the days between 2 dates not including Holidays? (I have calculated the labor days but they include holidays).

I have a table like this :

RQ   - Start_Date              -End_Date
A     - 01/01/2015             01/01/2016
B     - 08/07/2015              01/01/2016

And another query with holidays:

ID Date
1 - 25/12/2015
2-  01/01/2016
.
.
.




Title: Re: Calculate Days between 2 dates not including Holidays?
Post by: bdbits on 09 Dec 2015 03:47:47 PM
The best way is to add an attribute to your date dimension table (you do have one, right?) that indicates if it is a holiday.

But if you cannot do that, left outer join the two tables based on date, and only include those that have a null for the holiday side of the join.
Title: Re: Calculate Days between 2 dates not including Holidays?
Post by: cjsasaki on 09 Dec 2015 04:53:17 PM
Hi bdbits

My table :
ID - Date
1     24/12/2015
2    01/01/2016
etc

It is for holidays. So there are only the holidays. Should I add all the days?

But then on my 2nd table I have

RQ   - Start_Date              -End_Date
A     - 01/01/2015             01/01/2016
B     - 08/07/2015              01/01/2016


And I want to calculate the holidays between start_date and end_date on each row.Like this :

RQ   - Start_Date              -End_Date           Holidays
A     - 01/01/2015             01/01/2016         1
B     - 08/07/2015              01/01/2016        2

Can this be possible?
Title: Re: Calculate Days between 2 dates not including Holidays?
Post by: Lynn on 10 Dec 2015 02:32:12 AM
This thread might be useful:

http://www.cognoise.com/index.php/topic,28179.msg91275.html#msg91275
Title: Re: Calculate Days between 2 dates not including Holidays?
Post by: bdbits on 11 Dec 2015 04:44:32 PM
Good one Lynn. I never remember to search the forum for past discussions.  :o

The way the guy did it (last post) is pretty much what I had in mind when I lightly tossed out the suggestion to add it to the date table.