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)
In BIRT how to change the default time range into week base
Zsy Zang
<p>Hi everyone,</p>
<p> </p>
<p>I meet a problem that I have two parameters, the start date and end date. I want the default date automatically change into week base. For example, today is may 24, so the default start date should be may 17, and the default end date should be today, and then tomorrow the default date would be automatically change. How can I do that, can anyone help me?</p>
<p> </p>
<p>Response would be greatly appreciated</p>
<p> </p>
<p>Many thanks</p>
Find more posts tagged with
Comments
Matthew L.
<p>You can use the <a data-ipb='nomediaparse' href='
http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.birt.doc/birt/ScriptingReference.25.3.html'>BirtDateTime
Functions</a> to get this result.</p>
<p>Here is some code you can use in the parameter's Expression Builder to return the result you are looking for.</p>
<p>I've also attached an example report to demonstrate its behavior. </p>
<pre class="_prettyXprint _lang-js">
//StartDate Parameter
var firstDayOfTheWeek = BirtDateTime.firstDayOfWeek( BirtDateTime.today()); //Get first day of the current week
if(firstDayOfTheWeek.getTime() == BirtDateTime.today().getTime()) //If the first day of the week is today
BirtDateTime.addWeek( firstDayOfTheWeek , -1 ); //Use Sunday from last week
else
firstDayOfTheWeek; //Else use Sunday from this week
//EndDate Parameter
BirtDateTime.today(); //Get todays date
</pre>