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

Set First Date and Last Date of date prompt dynamically

Started by sthabinash, 08 May 2013 03:29:36 AM

Previous topic - Next topic

sthabinash

I would like to set the first Date and Last Date properties of the Date prompt dynamically. I have searched for the JavaScript but all I have found was setting the default date of the Date prompt.

Can anyone help me on this.

Jiayue.lin

this 2 javascripts are searched from internet, hope this may helps.

//the last day of the month
<script>
function ShowMonthLastDay()   
  {   
  var   Nowdate=new Date();   
  var   MonthNextFirstDay=new   Date(Nowdate.getYear(),Nowdate.getMonth()+1,1);   
  var   MonthLastDay=new  Date(MonthNextFirstDay-86400000);   
  var   strMonthLastDay = [MonthLastDay.getUTCFullYear(), MonthLastDay.getMonth()+1, MonthLastDay.getDate()].join("-");
  return strMonthLastDay;
  }
pickerControlPDate.setValue( ShowMonthLastDay() );
</script>



//the first day of the month
<script>
function subtractDay ()
{
var dtToday = new Date();
var strYesterday = [dtToday .getUTCFullYear(), dtToday .getMonth()+1, 1].join("-");

return strYesterday;
}
pickerControltext2.setValue( subtractDay() );
</script>

sthabinash

Hello Jiayue.lin

The solution you mentioned will set only the default date of the date prompt and not set the range.   :'(

sharathhs

Hi sthabinash,

Kindly let me know if you got any solution to set First date and Last date dynamically. I am also stuck with the same issue  :(

~Sharath

sthabinash

Hello Jiayue.lin,

Sorry for the late reply, but I didn't find any solution to it. So had to drop the idea and find a way around it. If you find any solution to it please let me know as well. It might be helpful for future. Will let you know if I come across any solution.

Jiayue.lin

sure...sthabinash... sorry i was busy these days...will try to solve it asap and let you know  :)

patrickthatcher

I have a similar requirement.  Was this ever figured out?  For my requirement, I have query in the report that will provide the First and Last dates.
Thank you

BigChris

This doesn't set the dates in the prompts, but it might give you an alternative approach...

http://cognostips.weebly.com/blog/date-prompts

patrickthatcher

Thanks. They really want the calendar to not allow the user to select a date earlier than the available data.
(vent time: even though we provide text below the calendar letting them know the earliest date! )

Lynn

Another option to consider is checking the dates once they run the report and then conditionally rendering a page that lets them know they didn't pick a date within the available range. The "real" report pages would only render when they satisfy the date selections properly.

On the error page you could include a text item that says something like "Click here to try again". Put a drill through definition on the text item to call the same report. The report simply drills through to itself giving them the prompt page all over again where they will, hopefully, pay more attention to the instructions about the earliest available date. If you're in a crabby mood you could make the text say something a little more belligerent  ;)

Also note that when you develop a report that drills through to itself you'll need to save it each time before you run in Report Studio to test.