Discussions
Categories
Choose a Product
THRUST SERVICES
CORE APPS
CE PRODUCTS
...
Quick Links
POPULAR
HELPFUL TIPS
Groups
My Links
FOR SIGNED IN MEMBERS:
Back to website
Home
Designing Analytics Reports
Date manipulation in expression builder
Migrateduser
<p>Hi,</p>
<p> </p>
<p>I have a problem with converting strings to dates (and will probably have a problem converting back for display).</p>
<p> </p>
<p>Incoming strings for a column look like this:</p>
<p>01-2014</p>
<p>03-2014</p>
<p>10-2014</p>
<p> </p>
<p>I need BIRT to see these months as dates, then display them as 'Mar 2014', 'Oct 2014' etc.</p>
<p> </p>
<p>So, my thinking was getting the expression builder to "fake" the dates at binding level on the chart that will display the data: the code for the column looks like this-</p>
<p> </p>
<div>var input = dataSetRow["MONTH"];</div>
<div>var mon = input.substr(0,2);</div>
<div>var year = input.substr(3,4) + "-";</div>
<div>var day = '-01';</div>
<div>var concat = year + mon + day;</div>
<div>return new Date(concat);</div>
<div> </div>
<div>If it returned the correct date, I could then try and format the date as 'MMM yyyy' for display.</div>
<div> </div>
<div>I've tested this Javascript elsewhere, and there's no problem. But the data preview is coming back with a standard linux date (1970), so I can't work out where it's tripping up. (The column at data binding has been changed to Date not DateTime, and I added a new column binding which didn't work either)</div>
<div> </div>
<div>Any ideas please?</div>
<div> </div>
<div>Thanks</div>
Find more posts tagged with
Comments
There are no comments yet