Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Date Formatting
Jodin
I don't know if anyone has noticed this before. I've seen it many times but always just fixed it and moved on. This morning I kind of took pause and decided to communicate this quirk of BIRT. I'm also going to add this to my own help documentation. I have two date parameters with custom formatting of MM/dd/yyyy which is our report standard. When I go to display these parameters, BIRT shows their values as yyyy-MM-dd. Why it does this I have no idea, but below is the Javascript I came up with to handle it. Note that the dates have to be converted to strings before having Javascript string functions put on them.
'From ' + params["rpBegDate"].toString().substr(5,2) + '/' + params["rpBegDate"].toString().substr(8,2) + '/' + params["rpBegDate"].toString().substr(0,4) + ' Thru ' + params["rpEndDate"].value.toString().substr(5,2) + '/' + params["rpEndDate"].toString().substr(8,2) + '/' + params["rpEndDate"].toString().substr(0,4)
Find more posts tagged with
Comments
mwilliams
How are you formatting your parameters?
Jodin
I'm using BIRT 2.3.1. The data type of the parameter is set to Date and the format I'm specifying is MM/dd/yyyy. Please see the following screenshot.<br />
<br />
<a class='bbc_url' href='
http://img820.imageshack.us/i/dateparameter.jpg/'>My
link</a>
Jodin
Any ideas why BIRT turns MM/dd/yyyy to yyyy-MM-dd? Is it to comply with ISO?
mwilliams
I don't know that there's a specific reason that BIRT treats dates in that format. It may just be because the sample database is set up that way. I'm not sure. BIRT stores the parameter in the format of yyyy-MM-dd no matter what you put for the format in your parameter editor. That is for formatting the way the data is displayed in your parameter page, I believe. If you really want to reformat the parameter value to be able to use it without your messy calculation above, you should be able to do something like this in your script:
df = new Packages.java.text.SimpleDateFormat("yyyy/MM/dd");
params["paramName"].value = df.format(params["paramName"].value);