Home
Analytics
Subtract two Date and get the full year
mdu_gprabh
Hi,
I need to subtract 2 days from the current date and extract the full year out of it.
I tried the below mapping
DateTimeSpan.subDate(new Date(),0,0,0).getFullYear()
but throwing an exception "The data type of computed colum is java.lang.string, but one of its value is "null", which cannot be converted to java.lang.string"
But the mapping works fine for extracting month and date
DateTimeSpan.subDate(new Date(),0,0,0).getMonth();
DateTimeSpan.subDate(new Date(),0,0,0).getDate();
Please help me in resolving it
Thanks in Advance,
Prabu G
Find more posts tagged with
Comments
mwilliams
Hi Prabu G,
What version of BIRT are you using? Can you set this up how you have it with a sample report made from the sample database? This way I can see exactly where you're doing this.
mdu_gprabh
I am using Actuate BIRT 2.2.2.
Attached the report design for your reference. In the design,
the computed Column a and c works fine but b to extract the year is throwing an exception.
Thank you.
Prabu G
mwilliams
Prabu G,
It looks like there was a problem with getFullYear and 2.2.2. If you use the getYear() function instead and add 1900 to the returned value, you'll get the correct year.
Hope this helps.
mdu_gprabh
Hi Michael,
Thankyou very much. That worked.
Thanks,
Prabu G
mwilliams
No problem! Glad to help!