COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: handpass on 29 Jan 2007 09:14:34 AM

Title: Date Timeframe, remove Saturday and Sunday.
Post by: handpass on 29 Jan 2007 09:14:34 AM
Hi,
          I am using Report Studio to develop reports for a manufacturing plant. In one of my reports I have a start-date and a finish-date, which I subtract from one another in order to get the number of days it took for a process to run.

The start and finish date can be weeks apart and I would like to just count working days, Monday - Friday. Is there anyway that I can remove the days Saturday and Sunday from the calculation?

Regards.
Title: Re: Date Timeframe, remove Saturday and Sunday.
Post by: MFGF on 31 Jan 2007 01:02:33 PM
Hi,

I had an old example of this from back in the days of Impromptu.  I have quickly modified it to make it suitable for Report Studio, but I'd advise you to test it well to ensure I've got it right.

Three query calculations are required, as follows:

Working Days from 1900 to Start Date:
  (floor(_days_between([Start Date],1899-12-31)/7) * 5) + (mod(cast(_days_between([Start Date],1899-12-31), integer),7))

Working Days from 1900 to End Date:
  (floor(_days_between([End Date],1899-12-31)/7) * 5) + (mod(cast(_days_between([End Date],1899-12-31), integer),7))

Working Days from Start Date to End Date Inclusive:
  if ( mod (cast(_days_between([End Date],1899-12-31),integer) , 7 )  = 6) then ([Working Days from 1900 to End Date] - [Working Days from 1900 to Start Date])
  else ( [Working Days from 1900 to End Date] - [Working Days from 1900 to Start Date] + 1 )


Hope this gives you what you need!

Best regards,

MF.