If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

How to get the Date from a Date prompt?

Started by pcog, 13 Mar 2014 02:09:39 PM

Previous topic - Next topic

pcog

I'm trying to display the Date prompt value on the page header. I know we can use the layout calculation to get this. but, my date prompt has in_range property set to yes. Still layout calculation will work, but it will display as between 'date' and 'date' for ex: if I select the range as Mar'13 2013 and Mar'13'2014 it displays as Between Mar 13, 2013 and Mar 13, 2014
But, I want to display the selected date as From Mar 13, 2013 through Mar 13, 2014. So, if I get the date parts from the in_range date prompt I can display as I expected.
any help is appreciated!

navissar

Interesting.
If you filter you're query with a date range, how can you pull up the first and last date? Well, it's going to filter the dates, isn't it? So your first date in the query is from, and your last date is the to date, aren't they?  ;)
I'm guessing you're on relational, so here's a rough example of how to get that:
Add a query which takes "Date" from date dimension and is filtered by the date range prompt. Add two data items, one that calculates the maximum date (maximum([date] for report) and another one that does the same for minimum. Then on the report page add a text item, a singleton, another text item and another singleton, and set them up like this:
first text item: "From " first singleton <minimum date data item> second text item " Through " second singleton <maximum date data item>
You could also throw them all in a container such as a repeater not set to repeat or a single singleton, add Minimum and Maximum data items in the properties, and drag in a single layout calculation with 'From '+[query].[minimum val]+' Through '+[query].[maximum val]

On dimensional it's also possible using head/tail and the date range as a set.

Hope this helps!

pcog

Nimrod,
I tried your solution and It's sort of working.
Two Issues though.

1. It is displaying the TIME part also. I used cast function to convert to date, but it is giving an error as Prompt 'p_Date' is used multiple times with conflicting data types.

2. As I mentioned in my earlier post, the date prompt is using a range. By default, it selects earliest date and latest date as a prompt. In this case the date is displaying from the earliest date from the database. I don't know why FOR REPORT is not working. But, When we run the report by selecting a specific date range then it is displaying the date as accurately.

This is what I did.
1. Created a new query with one of the date data item which is using in the report.
2. added a filter like [Date] in_range ?pDate?
3. Created a two data items based on Date data item.
   ex: maximum([Date] for report)
       minimum([Date] for report)
Using the above 2 data items in the report header using a singleton.

navissar

1. Try casting the maximum and minimum items :
Cast(maximum([date]), date)
2.try the expression without "for report".

pcog

Sorry for the late reply.
somehow it is not working properly, but now I had to use the 2 parameters for the date range. so, there is no issue now.
Thanks for your help though  :)