COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: diasbrad on 09 Jan 2015 02:17:10 AM

Title: Logic for next 7 Days
Post by: diasbrad on 09 Jan 2015 02:17:10 AM
Hi Friends,

I have a report where I need to generate next 7 days date.

For example I have a prompt Value 20-11-2014. then the query should generate the following 6 days automaticly.

So the out put should look like this

Date Field
20-11-2014 (Prompt date)
21-11-2014 Auto Generated by query
22-11-2014 Auto Generated by query
23-11-2014 Auto Generated by query
24-11-2014 Auto Generated by query
25-11-2014 Auto Generated by query
26-11-2014 Auto Generated by query

Is this possible in report studio

Thanks & Regards
Brad
Title: Re: Logic for next 7 Days
Post by: BigChris on 09 Jan 2015 02:38:21 AM
[Date] <= _add_days(?prompt_date?,6)
Title: Re: Logic for next 7 Days
Post by: diasbrad on 09 Jan 2015 02:56:48 AM
Thanks Chris for your reply.

I do not want to get the date from the database I want to create dummy dates based on the prompt value that the user inputs.

Example if a user enter a date 20-November-2014 the frist day i.e. 20-November-2014 will be displayed as per prompt value and the next 6 days date will be auto generated .

The function that you mentioned will only work if there is  data in the database. Even if data is not present in the database it should show me 7 day dummy date by default.

Thanks & Regards
Bradley
Title: Re: Logic for next 7 Days
Post by: spmaganti on 09 Jan 2015 07:57:50 AM
Usually

1. You need to get the dates from a calendar from the database or
2. You could build a custom calendar in FrameWork manager if you have access to modify the package

If not try and use this SQL in the report studio with Query (SQL). This is for an oracle db

SELECT
    to_date(#sq(prompt('SelectedDate','date'))#,'yyyy-mm-dd') + 6 - LEVEL "Date List"
FROM
    dual CONNECT BY LEVEL <= 6

My two cents
Title: Re: Logic for next 7 Days
Post by: akash_d on 12 Jan 2015 10:57:01 PM
Hi,

For what it's worth, you can generate the day for next 7 days using Javascript. The logic can be something like this:

Consider your prompt is dtToday.

Add a hidden Date time picker prompt and add folowing code to the Javascript you call for validation after clicking submit.

var dtTomorow = new Date( dtTodayUTC.getUTCFullYear(),dtTodayUTC.getMonth(),dtTodayUTC.getDate() + 1 );

var strTomorow = [dtTomorow.getUTCFullYear(), dtTomorow.getMonth()+1, dtTomorow.getDate()].join("-");

pickerControlEndPrompt.setValue( strTomorow );
timePickerEndPrompt.setValue( eTime );

This method is useful if you don't want to use the database for fetching the next 7 days.

Hope this helps  :)