COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: sakthivelmani on 20 Aug 2016 08:52:29 PM

Title: How to make sysdate as default for optional date prompt
Post by: sakthivelmani on 20 Aug 2016 08:52:29 PM
Hi All,

I have a report where i have an optional date prompt. I want the report studio to use sysdate if the user doesn't select a date. I tried several ways and nothing worked. Can you guys help me ?

Thanks,
MS
Title: Re: How to make sysdate as default for optional date prompt
Post by: MFGF on 22 Aug 2016 03:46:45 AM
Quote from: MS on 20 Aug 2016 08:52:29 PM
Hi All,

I have a report where i have an optional date prompt. I want the report studio to use sysdate if the user doesn't select a date. I tried several ways and nothing worked. Can you guys help me ?

Thanks,
MS

Hi,

How about using a prompt macro with $current_timestamp as the default value argument for this:

[Your date item] = #prompt('Your parameter', 'date', $current_timestamp)#

MF.
Title: Re: How to make sysdate as default for optional date prompt
Post by: sakthivelmani on 24 Aug 2016 10:05:20 PM
Thanks MFGF. It was throwing error for some reason. but this worked.

to_date (#sq(prompt('Selected Date', 'date', '2007-09-09'))# , 'YYYY-MM-DD' )
Title: Re: How to make sysdate as default for optional date prompt
Post by: sakthivelmani on 25 Aug 2016 09:03:10 AM
Actually, this worked without hard coded date

to_date (#sq(prompt('Selected Date', 'date', timestampMask ( _add_days ( $current_timestamp , -1 ) , 'yyyy-mm-dd' )
))# , 'YYYY-MM-DD') 


Thanks again MFGF.
Title: Re: How to make sysdate as default for optional date prompt
Post by: dougp on 25 Aug 2016 11:34:38 AM
How did you make the date prompt default to blank?  ...or how did you make the date prompt default to your calculated date?
Title: Re: How to make sysdate as default for optional date prompt
Post by: sakthivelmani on 30 Aug 2016 08:19:36 AM
Hi Dougp, I don't understand your question.
Title: Re: How to make sysdate as default for optional date prompt
Post by: AnalyticsWithJay on 30 Aug 2016 09:38:05 AM
Quote from: dougp on 25 Aug 2016 11:34:38 AM
How did you make the date prompt default to blank?  ...or how did you make the date prompt default to your calculated date?

They're using a prompt macro (#prompt()#), and one of the parameters is defaultValue. You can specify a literal or function for this parameter. If no value is selected in the prompt, it will use defaultValue.