Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Formatting date in Dynamic text
Formatting date in Dynamic text [message #652609] Fri, 04 February 2011 17:16 Go to next message
Nicola is currently offline NicolaFriend
Messages: 184
Registered: July 2009
Senior Member
Hi,
I have a dynamic text which should display:

Exam n. 1234/2011 of 01/04/2010

Inside the dynamic I have

'Exam n. ' + row["number"] + ' of ' + row["date"]

but the result is:

Exam n. 1234/2011 of Thu Apr 01 00:00:00 CEST 2010


How can I format the date inside a dynamic text?
Should I do it from sql side?

Thank you
Nicola
Re: Formatting date in Dynamic text [message #652645 is a reply to message #652609] Fri, 04 February 2011 19:59 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Nicola,

There a couple of ways you could do this. You could use a text element
instead of a data element and do something like:
<VALUE-OF>row["number"];</VALUE-OF><VALUE-OF format="MM/dd/YYYY"
row["date"]</VALUE-OF>

or

in your data item expression do something like:

importPackage( Packages.java.text );
var sdf = new SimpleDateFormat("MM/dd/YYYY", reportContext.getLocale());
var myformatteddate = sdf.format( row["date"]);
row["number"]+' of ' + myformatteddate.


Jason

On 2/4/2011 12:16 PM, nicola wrote:
> Hi,
> I have a dynamic text which should display:
>
> Exam n. 1234/2011 of 01/04/2010
>
> Inside the dynamic I have
>
> 'Exam n. ' + row["number"] + ' of ' + row["date"]
>
> but the result is:
>
> Exam n. 1234/2011 of Thu Apr 01 00:00:00 CEST 2010
>
>
> How can I format the date inside a dynamic text?
> Should I do it from sql side?
>
> Thank you
> Nicola
Re: Formatting date in Dynamic text [message #652939 is a reply to message #652609] Mon, 07 February 2011 17:04 Go to previous message
Richard A. Polunsky is currently offline Richard A. PolunskyFriend
Messages: 199
Registered: July 2009
Location: Houston TX
Senior Member

I'd lean toward doing it on the SQL side.
If you have to do it in the BIRT side, you'll need to reference the Java SimpleDateFormat library (I think) and make calls using those methods. Someone else can probably point you to examples.
Previous Topic:How to propagate a Data Source to sub reports?
Next Topic:Y axis showing exponential value
Goto Forum:
  


Current Time: Wed Nov 26 16:50:03 GMT 2014

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

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