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)
DateTimeSpan.days() in Birt 2.2.2
cypherdj
Hi,<br />
<br />
I need to compute the number of days between 2 dates, 1st date extracted from CSV, 2nd date being a Date report parameter.<br />
<br />
In the expression builder, I found the DateTimeSpan.days() function, which sounds like it should do what I'm looking for.<br />
<br />
I set a default value for my parameter to today's date.<br />
<br />
However, when I add a computed column to my data set:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
DatetimeSpan.days(new Date(params["reportDate"]), row["datecreated"])
</pre>
<br />
and preview the results, I get rather unexpected values in my computed column (see attached screenshot).<br />
<br />
When I don't use new Date() around my parameter, I get the following error:<br />
"The data type of the computed column 'dateDiff' is java.lang.Integer, but one of its values is 'null', which cannot be converted to java.lang.Integer".<br />
<br />
Any idea what I'm doing wrong here?<br />
Thanks,<br />
Cedric
Find more posts tagged with
Comments
cypherdj
I found a way around this by first adding the report parameter as a computed column, then using it in the expression builder.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
DateTimeSpan.days(row["paramDate"], row["DATECREATED"])
</pre>
<br />
How bizarre!
mwilliams
Cedric,
I had an IntervalInMinutes report I had done using the DateTimeSpan and tried out the Interval in Days in the same report only with a parameter as one date and didn't have any problems using the format "DateTimeSpan.days(params["Date"], row["DateTime"])". Is that line of code you posted the only thing you had in your computed column?