COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: vaneetdhiman on 26 Jul 2012 10:46:40 PM

Title: Count Number of days between two selected dates
Post by: vaneetdhiman on 26 Jul 2012 10:46:40 PM
Hi All,

I am required to calculate number of days between two slected dates at the prompt. For example, if a user selects 1 July,2012 as start date and end date as 7 July, 2012; the expression should tell me the number of Mondays (1), Tuesdays (1), Wednesdays (1), Thursdays(1) and Fridays(1).

I am using the following expression condition but it is not calculating properly. Can someone please let me know what is wrong with my expression?

round((_days_between (cast(?End Date?,date),_add_days(cast(?Start Date?,date),1)) - mod (2-(_days_between (cast(?Start Date?, date), 1900-01-01)),7)
)/7,0)

Thanks in advance.

Cheers, V
Title: Re: Count Number of days between two selected dates
Post by: pricter on 27 Jul 2012 07:16:24 AM
I propose to use three query items
The first one would be the [Date] in which are you going to apply the filter based on users selection
The second one would be the [Weekday] (for example you can fine which day of the week is from the date)
The third one [Count of Weekday] with expression count([Weekday]"
Title: Re: Count Number of days between two selected dates
Post by: vaneetdhiman on 29 Jul 2012 07:41:56 PM
Thanks pricter for your quick reply, appreciated. I will give a go to the suggested solution by you and will let you know if it worked for me.

However, considering my expertise oin Cognos, it may take me sometime :)

Anyway, thanks for your help :)