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)
How to set date time parameter for dataset programatically
jmuthuku
<p>Hi,</p><p> I have a SQL based dataset with 2 parameters of type DateTime. I am trying to set the values for the parameters in beforeOpen as follows:</p><pre class="_prettyXprint">....} else if (reportContext.getParameterValue("period").equals("monthly")) {var date = new Date();var startDate = new Date(date.getFullYear(), date.getMonth(), 1);var endDate = new Date(date.getFullYear(), date.getMonth() + 1, 0);this.setInputParameterValue("startDate", startDate);this.setInputParameterValue("endDate", endDate);} .. ..</pre><div> </div><div>But when I run the report I get the following error:</div><div>[color=#ff0000;]<span>- [/color]An exception occurred during processing. Please see the following message for details:<br />
Failed to prepare the query execution for the data set: CompletedJobsByRole<br />
<span class='bbc_underline'>Cannot convert the parameter value org.mozilla.javascript.NativeDate@b4fe832 to type class java.sql.Timestamp.<br />
Can not convert the value of org.mozilla.javascript.NativeDate@b4fe832 to Date type. (Element ID:824) exception.error ( 1 time(s) )</span><br />
detail : org.eclipse.birt.report.engine.api.EngineException: An exception occurred during processing. Please see the following message for details:<br />
Failed to prepare the query execution for the data set: CompletedJobsByRole<br />
Cannot convert the parameter value org.mozilla.javascript.NativeDate@b4fe832 to type class java.sql.Timestamp.<br />
Can not convert the value of org.mozilla.javascript.NativeDate@b4fe832 to Date type. (Element ID:824)<br />
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1237)<br />
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1216)</span></div><div> </div><div>I'd appreciate if someone could help. Some sample code would be even better. Thanks</div><div> </div><div>btw, the idea is to get the start and end dates of the current month and pass it to the query.</div><div> </div><div>- J</div>
Find more posts tagged with
Comments
kclark
<p>Are you doing this with the sample DB or your own data? If it's your own data what format are the dates stored as in the DB?</p>
jmuthuku
<p>hi,</p><p> Thanks for getting back.</p><p> </p><p>I am using my own data from a Postgres database. The date format is "2013-07-18 23:20:10.002753+00".</p><p> </p><p>Thanks again.</p>
kclark
<p>Can you post your rptdesign with some sample data in xml format for me to test with so I can write an example for you?</p>
jmuthuku
<p style="color:#000000;font-family:helvetica, arial, sans-serif;">Hi,</p><p style="color:#000000;font-family:helvetica, arial, sans-serif;">I have attached a sample rptdesign file here. Based on the parameter value selected (monthly/weekly) i am trying to compute the start and end dates of the month/week and set the parameter value in the beforeOpen method of the dataset.</p><p style="color:#000000;font-family:helvetica, arial, sans-serif;"> </p><p style="color:#000000;font-family:helvetica, arial, sans-serif;"> When I run the report based on the sampledb it doesn't show any data because the order dates in the sample are not in the current month/week. I don't know how to alter the data in the sampledb so that i can simulate it exactly the way my actual report that goes after a postgres database. But it may give you an idea of how my code looks like and if I have made any mistakes in it.</p><p style="color:#000000;font-family:helvetica, arial, sans-serif;"> </p><p style="color:#000000;font-family:helvetica, arial, sans-serif;">Thanks again.</p><p style="color:#000000;font-family:helvetica, arial, sans-serif;"> </p><p style="color:#000000;font-family:helvetica, arial, sans-serif;">- J</p>