Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Date parameters..
Anter
Hi all,
I create report with two date parameters.
How i can to do the default date parameters,
first parameter: beginning of current month,
second parameter: the end of current month.
Thanks
Find more posts tagged with
Comments
mwilliams
Hi Anter,
What version of BIRT are you using? If it was january, you'd want the defaults to be 2010-01-01 and 2010-01-31? Is this correct?
johnw
Unless something has changed in recent versions of BIRT, I'll recommend the same thing I always do. just create your two date parameters, and use an external parameter page to call your report. There isn't a real easy way to assign default date parameter values without modification. It can be done, but they won't show up in the parameter dialog in the BIRT viewer.
Anter
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>Hi Anter,<br />
<br />
What version of BIRT are you using? If it was january, you'd want the defaults to be 2010-01-01 and 2010-01-31? Is this correct?</p></blockquote>
<br />
I using a birt-rcp-report-designer-2_2_2, yes i want the defaults to be 2010-01-01 and 2010-01-31 for january, 2010-02-01 and 2010-02-31 for february etc.
mwilliams
Anter,<br />
<br />
This devShare post may help you with that by using a scripted dataSet:<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/devshare/designing-birt-reports/687-set-a-date-parameter-value-to-last-day-of-the-month/#description'>Set
a Date Parameter Value to last day of the month - Designs & Code - BIRT Exchange</a>
Anter
Thanks Michael,
I wrote 2 scripts, first for begin of current month:
_____________________________________________
var today=new Date();
var day=today.getDate();
DateTimeSpan.addDate(today,0,0,-day+1)
_____________________________________________
and second, for the end of current month:
var today=new Date(); var t=today.getMonth(); var day=today.getDate();
var i=31; var j=30; var l=28;
var m=i-day; var n=j-day; var b=l-day;
if ((t==2.0) || (t==4.0) || (t==0.0) || (t==6.0) || (t==7.0) || (t==9.0) || (t==11.0)){
DateTimeSpan.addDate(today,0,0,m)
} else if ((t==3.0) || (t==5.0) || (t==8.0) || (t==10.0)){
DateTimeSpan.addDate(today,0,0,n)
} else { DateTimeSpan.addDate(today,0,0,b) }
______________________________________________
How I can now set the default these parameters, using written scripts?
Regards
mwilliams
Anter,
The way that the one in the example was done was by using a combo box type parameter. You could either use the default date, which was the end of the month, or you could select the text entry and enter your own date. If this way is not acceptable, John's suggestion is probably going to be the way to go. In 2.5.1, the default value can be set using javascript syntax. This new feature should allow the setting of the parameter to the last day/first day more easily. However, that would require you to upgrade from 2.2.2, which may not be an option for you.
Anter
Thanks Michael, you help me again!
I download new version, and it's work.
mwilliams
Anter,
No problem! Let us know whenever you have questions!