COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: Prakash Bhai on 04 Jul 2011 07:57:57 AM

Title: how to extract weekend date from the current date
Post by: Prakash Bhai on 04 Jul 2011 07:57:57 AM
Hi Gurus,

how to extract weekend date from the current date.
Ex: I need to get the dynamic weekend dates from the souce of dates which has all weekend dates... when I run a report I need to get the weekend date of that particular week dynamically.

i.e..If I run the report in this week I need to get 8-7-2011 dynamically.cos as 8-7-2011 will be last day of weekend.

Regards,
Ram
Title: Re: how to extract weekend date from the current date
Post by: CognosPaul on 04 Jul 2011 09:58:57 AM
You'll need to use a dayofweek function for this. Essentially you need to do something like:

add_days([Date], (7 - dayOfWeek([Date])))

Depending on your DB settings this would either return the Sunday or Saturday.

If you're using Oracle you could use the next_day function. next_day([Date],'Saturday')