Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Convert String to Datetime in Expression Builder
Asmrani
Hello All,
I'm trying to convert this string format:
06/30/2008 10:50 to
2008-06-30 10:50
I tried it with BIRT 2.3 Expression Builder, but it does not seem to recognize that that string is a date.
Any useful ideaS?
Thanks
Find more posts tagged with
Comments
cypherdj
Hi Asmrani,<br />
<br />
I was able to produce what you want (see full report attached). I used a String parameter which contains the date/time in your specified format. I then created data element on the report and set its expression to the following:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage(Packages.java.text);
sdf = new SimpleDateFormat("MM/dd/yyyy H:m");
sdf.parse(params["reportDate"]);
</pre>
<br />
Finally, I used a Custom format for the Date Time, using the following format code: yyyy-dd-MM HH:mm<br />
<br />
Hope that does what you're looking for,<br />
Regards,<br />
Cedric
Asmrani
<blockquote class='ipsBlockquote' data-author="cypherdj"><p>Hi Asmrani,<br />
<br />
I was able to produce what you want (see full report attached). I used a String parameter which contains the date/time in your specified format. I then created data element on the report and set its expression to the following:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage(Packages.java.text);
sdf = new SimpleDateFormat("MM/dd/yyyy H:m");
sdf.parse(params["reportDate"]);
</pre>
<br />
Finally, I used a Custom format for the Date Time, using the following format code: yyyy-dd-MM HH:mm<br />
<br />
Hope that does what you're looking for,<br />
Regards,<br />
Cedric</p></blockquote>
<br />
Many thanks Cedric!!