Skip to main content



      Home
Home » Archived » BIRT » Formatting date in Dynamic text
Formatting date in Dynamic text [message #652609] Fri, 04 February 2011 12:16 Go to next message
Eclipse UserFriend
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 14:59 Go to previous messageGo to next message
Eclipse UserFriend
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 12:04 Go to previous message
Eclipse UserFriend
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 Jul 23 17:12:20 EDT 2025

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

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

Back to the top