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)
Dynamicall setting date Parameters
PikeyBoy
Sorry if this is an obvious one, but I am still new to this game. <a class='bbc_url' href='
http://www.birt-exchange.org/org/forum/public/style_emoticons/'>http://www.birt-exchange.org/org/forum/public/style_emoticons/</a><#EMO_DIR#>/confused.gif
<br />
<br />
I am trying to run a report between two dates, the 'from date' I want to be today less 12 months and the 'to date' I want to be today.<br />
<br />
Thanks in advance for any help.
Find more posts tagged with
Comments
mwilliams
So, you want it to be the past year no matter what? No user interaction at all? No possibility for them to change the range?
If not, if you're using a SQL query, you can define your "where" statement in the beforeOpen script of your query. You'd already have the select/from portions defined, then in your beforeOpen it'd be something like:
whereClause = " where myDate between '"BirtDateTime.addYear(new Date(), -1).toString() + "' and '" + new Date().toString() + "'"; Or something similar. You will probably have to format the date to that of your database for it to work.
PikeyBoy
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="81245" data-time="1312808257" data-date="08 August 2011 - 05:57 AM"><p>
So, you want it to be the past year no matter what? No user interaction at all? No possibility for them to change the range?<br />
<br />
If not, if you're using a SQL query, you can define your "where" statement in the beforeOpen script of your query. You'd already have the select/from portions defined, then in your beforeOpen it'd be something like:<br />
<br />
whereClause = " where myDate between '"BirtDateTime.addYear(new Date(), -1).toString() + "' and '" + new Date().toString() + "'"; Or something similar. You will probably have to format the date to that of your database for it to work.<br /></p></blockquote>
Hi Michael,<br />
<br />
Thanks for that but unfortunatly yes I doi want them to be able to change the dates, but with the range I specified as the defaults.<br />
<br />
Cheers<br />
<br />
Ian
mwilliams
Ok, then you'd just create two report parameters, one for start date and one for end date. You can use the expression builder for each to create the defaults as I did in the script above. In your query, you'd have your query like:
select * from myTable where date between ? and ?
This will create parameters in your dataSet. You'll now link these to your report parameters you created. Now there should be text box options for the user to enter dates, but they'll be filled with your defaults to start with.
PikeyBoy
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="81248" data-time="1312811635" data-date="08 August 2011 - 06:53 AM"><p>
Ok, then you'd just create two report parameters, one for start date and one for end date. You can use the expression builder for each to create the defaults as I did in the script above. In your query, you'd have your query like:<br />
<br />
select * from myTable where date between ? and ?<br />
<br />
This will create parameters in your dataSet. You'll now link these to your report parameters you created. Now there should be text box options for the user to enter dates, but they'll be filled with your defaults to start with.<br /></p></blockquote>
<br />
Thanks.
mwilliams
Not a problem. Let us know whenever you have questions!