Skip to main content



      Home
Home » Archived » BIRT » How to set date parameter as today
How to set date parameter as today [message #225196] Wed, 14 March 2007 17:11 Go to next message
Eclipse UserFriend
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 #225287 is a reply to message #225196] Thu, 15 March 2007 04:49 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: How to set date parameter as today [message #225403 is a reply to message #225287] Thu, 15 March 2007 09:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dberman.tamaleresearch.com

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
Re: How to set date parameter as today [message #225435 is a reply to message #225403] Thu, 15 March 2007 10:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dyang.chestnet.org

Hi,

You might try
reportDate=reportContext.getParameterValue("ReportDate")
if (reportDate=null){do ......} in initialize event.
I used this way get the value from date parameter but I do not allow it
null. I want to set defaul as today when runing report and showing defaut
date paramter to my customer. That means customer see the date is today
and he/she can change the date. I can set the defaul date as "3/1/2007"
when I create the date parameter but I do not know how to set it as new
Date() as defaul in displaying parameter page.

Thanks!

Dan
Re: How to set date parameter as today [message #225647 is a reply to message #225403] Thu, 15 March 2007 16:32 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:Iterating parameters to see what's there?
Next Topic:Browser can remeber the pdf page I visited the last time?
Goto Forum:
  


Current Time: Sun Nov 09 01:48:04 EST 2025

Powered by FUDForum. Page generated in 0.03759 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top