Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How i set a value for a static parameter that depend of the today's date
cheli
Hello,
I need to use a parameter for decide since what day I'm going to show my results, for example, I want to offer 3 possibilitys: 30 days,60 days and 90 days before today and the today's date change everyday. these are static values and I can't use the javascript for set its values,how can I do that? Is it possible?
Thanks you very much, I wait your answers.
Find more posts tagged with
Comments
CBR
Thats possible for sure.
Just create a report parameter that let's the user choose between 30, 60 and 90 days. After the user chooses one of the options and your report is running you can simply use a BIRT javascript expression to calculate the start date. Let's say your report parameter (used to let the user choose one of the options above) is named timeSpan you can put the following snippet into the beforeFactory method of your report:
calendar = Packages.java.util.Calendar.getInstance();
calendar.add(Packages.java.util.Calendar.DATE, param["timeSpan"].value);
startDate = calendar.getTime();
now you can use startDate whereever you want. I think you want to use it as a parameter value inside of your sql query. For that just create a date parameter inside the parameter tab of your data set and set its value to startDate using the expression builder over there.
hope this helps
cheli
Thanks you very much CBR, your answer has been very useful