COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Framework Manager => Topic started by: sspk on 23 Jan 2008 11:58:58 AM

Title: create new query item
Post by: sspk on 23 Jan 2008 11:58:58 AM
Hi guys,
can any body help me in creating a query item "current week" using a query item called " inv_end_date".(i need the logic for 'current week')
Title: Re: create new query item
Post by: Suraj on 23 Jan 2008 01:28:47 PM
What is the logic for Current week? All 7 days or 5 days?
You can use this function to get the current week of the year.
_week_of_year(inv_end_date)
Title: Re: create new query item
Post by: sspk on 23 Jan 2008 02:01:48 PM
thank you, the logic is for all 7 days.week is from MON-SUN.I need to calculate the 'last 4 weeks' data item using the 'inv_end_date'.can you tell the following code is correct or not
_add_days(_week_of_year(inv_end_date),-28)
Title: Re: create new query item
Post by: blom0344 on 24 Jan 2008 10:11:53 AM
_add_days() expects a date as input , the _week_of_year has a numeric value as output.

Why not

_add_days(inv_end_date,-28) ?
Title: Re: create new query item
Post by: Suraj on 24 Jan 2008 11:58:34 AM
I second blom0344.
Keep in mind that this will give you rolling 28 days data.
If your objective is to get 4 weeks data till the start of current week, then it adds some more calculations.
Title: Re: create new query item
Post by: sspk on 25 Jan 2008 10:36:20 AM
Quote from: Suraj Neupane on 24 Jan 2008 11:58:34 AM
I second blom0344.
Keep in mind that this will give you rolling 28 days data.
If your objective is to get 4 weeks data till the start of current week, then it adds some more calculations.

HI ,
can you tell me what other calculations i need to add to get exact 4 weeks of data
Title: Re: create new query item
Post by: blom0344 on 26 Jan 2008 01:04:46 PM
Quote from: sspk on 25 Jan 2008 10:36:20 AM
HI ,
can you tell me what other calculations i need to add to get exact 4 weeks of data

It all depends on how you define exact 4 weeks.
If the week runs from monday to sunday , then use _day_of_week(date,1) to establish the daynumber of the date.
Say, the date is friday, then this yields 5.

The exact 4 whole weeks would be:

between (_add_days(date,-28-_day_of_week(date,1)) and
_add_days(date,0-_day_of_week(date,1)))