Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Formatting Date as String in script
Formatting Date as String in script [message #654858] Thu, 17 February 2011 13:12 Go to next message
Rick Seiden is currently offline Rick SeidenFriend
Messages: 4
Registered: August 2010
Junior Member
I have a report that takes to parameters--startDate and endDate.

I want to create a single element in my report that outputs them in a form similar to:

Closed from 1/1/2011 to 1/31/2011

I'm currently using the following code to do this:

"Closed from "+
(params["startDate"].value.getMonth()+1)+"/"+params["startDate"].value.getDate()+"/"+BirtDateTime.year(params["startDate"].value) +
" to "+
(params["endDate"].value.getMonth()+1)+"/"+params["endDate"].value.getDate()+"/"+BirtDateTime.year(params["endDate"].value)


And it works, but I'm thinking there has to be a more "graceful" way of doing this.

Can anyone point out a better way to do this?

Thanks
Rick Seiden
Re: Formatting Date as String in script [message #654942 is a reply to message #654858] Thu, 17 February 2011 17:09 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You could use a text element with syntax like:

"Closed from "+ <VALUE-OF format="MMM/dd/yy"
>params["startDate"].value</VALUE-OF> + " to " + <VALUE-OF
format="MMM/dd/yy" >params["endDate"].value</VALUE-OF>

Set the text type to html.

Jason

On 2/17/2011 8:12 AM, Rick Seiden wrote:
> I have a report that takes to parameters--startDate and endDate.
>
> I want to create a single element in my report that outputs them in a
> form similar to:
>
> Closed from 1/1/2011 to 1/31/2011
>
> I'm currently using the following code to do this:
>
> "Closed from "+
> (params["startDate"].value.getMonth()+1)+"/"+params["startDate "].value.getDate()+"/"+BirtDateTime.year(params["startDate "].value)
> +
> " to "+
> (params["endDate"].value.getMonth()+1)+"/"+params["endDate "].value.getDate()+"/"+BirtDateTime.year(params["endDate"].value)
>
>
> And it works, but I'm thinking there has to be a more "graceful" way of
> doing this.
>
> Can anyone point out a better way to do this?
>
> Thanks
> Rick Seiden
Previous Topic:BIRT Runtime Localizations Not Working
Next Topic:Double-byte characters not displayed in MS Word export
Goto Forum:
  


Current Time: Fri Apr 26 11:42:25 GMT 2024

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

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

Back to the top