| How to set date parameter as today [message #225196] |
Wed, 14 March 2007 17:11  |
Eclipse User |
|
|
|
Originally posted by: dyang.chestnet.org
Hi All,
I have two questions:
1.How do I set a date paramter as today?
2.Can I use the return collection for another dataset in a dataset I am
using?
Thanks!
Dan
|
|
|
|
|
|
| Re: How to set date parameter as today [message #225647 is a reply to message #225403] |
Thu, 15 March 2007 16:32  |
Eclipse User |
|
|
|
Originally posted by: johnw.innoventsolutions.com
See this script snippet, which demonstrates a script that will set a
date range to a YTD if the date range parameters are not set.
if (params["paramStartDate"].value == null)
{
var cal = java.util.Calendar.getInstance();
var parseMe = new java.text.SimpleDateFormat("MM/d/y");
//Used for YTD. This will set the date range from beginning of the
year to today
params["paramStartDate"].value = parseMe.parse("01/01/" +
cal.get(java.util.Calendar.YEAR));
params["paramEndDate"].value = new java.util.Date();
}
Sorry I didn't clean it up, I have it in the clipboard for a
presentation I am about to give. But this will set the date parameter to
the first of the year for start date, and today as the end date.
John
David Berman wrote:
> 70 wrote:
>> hi Dan,
>> i am not very sure what you wish to get.but in birt, if you want to
>> get today date, just use the script <value-of>new Date()</value-of>.
>>
>> hope this can help you
>>
>>
>
> I don't know what 70 is trying to do exactly but I have a date problem
> also. I want to pass in a Date as a report parameter. If the user
> specifies a date then I'm going to filer out all data before that date.
> However, if the user doesn't specify a date I want to use the current
> date as a default. The problem is how do I either tell birt to use
> today as the current date if no date parameter is specified, or in
> script detect that there was no value passed in and assign it to a date?
>
> For example:
> I create a report parameter "ReportDate" of type DateTime. I allow it
> to be a null value. When the report runs, BIRT pops up a window asking
> the user to enter a date or select the NULL radio button option for
> ReportDate parameter. If the user enters a date I'm fine. If the user
> doesn't enter a date, how can I detect this in script? I try this:
> if (params["ReportDate"] != null) // But this evaluates to true even
> if user select the null value
>
> so if Birt creates the param["ReportDate"] how can I detect that it is
> the NULL choice and not a date? If I try this:
> if (params["ReportDate"] != null) {
> MyDate = params["ReportDate"]; // If user selected NULL for
> date param, script crashes here.
> .. do stuff ..
> }
>
> Any ideas how to handle this?
>
> David
>
|
|
|
Powered by
FUDForum. Page generated in 0.04017 seconds