COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: gatorfe on 03 Nov 2010 10:04:08 AM

Title: NETWORKDAYS function in Available in Cognos?
Post by: gatorfe on 03 Nov 2010 10:04:08 AM
Hello.  Is there a function or way to tell the difference between two date fields in Cognos but just counting working days not Saturday or Sunday, just like the function in excel called NETWORKDAYS?  Thanks in advance for any comments!
Title: Re: NETWORKDAYS function in Available in Cognos?
Post by: phoenixfire on 05 Nov 2010 07:05:34 PM
Hi,
I did this a few months ago. There is no straight forward function. Basically, you would have to write a code that goes something like this

Date Dif = Date 1 - Date 2
Use this Date Dif as the base value

If dayoftheweek for Date 1 equals 1, it means its a monday - day of the week is a function that can be used to find out the day of that particular date - 1 is monday, 2 is tuesday and so on.

So if Date 1 equals monday and
date dif < 5 (5 being the business days in the week)
then date dif becomes the number of business days between date 1 and date 2
date dif equals 5 or 6
then date dif is 4. ( since if monday is 1, then date dif 5 days brings it to saturday and 6 brings it to sunday)
date dif >= 7
calculate the value.

You have to do the above exercise for each day of the week...In the end you will end up with a monstrous code that only you will be able to understand.

There might be an easier method - but I searched everywhere and this was the best I could come up with.

Maybe someone else has a simpler solution 8)