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)
Problems Setting Date
AlanC
I'm tearing out what little hair I have left over this! It may be something simple that I'm missing.
I'm trying to set a parameter value to today's date (without any time part).
I've tried the following code:
if (params["p_EDate"].value == null)
{
var m0 = new Date();
var m1 = BirtDateTime.year(m0);
var m2 = m0.getMonth();
var m3 = m0.getDate();
globaltoday = new Date(m1,m2,m3);
reportContext.setParameterValue("p_EDate", globalToday);
}
This gets the following error message when I run the report:
"Report generation failed! Cause: Unhandled exception when executing script."
I've tried setting
globalToday = new Date();
but this gives me a date with the current time as well.
Can anybody shed any light?
Find more posts tagged with
Comments
mwilliams
Hi AlanC,<br />
<br />
You might try formatting it before you put it in the parameter. Maybe something like the following:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
globalToday = new Date();
df = new Packages.java.text.SimpleDateFormat("MM/dd/yyyy");
globalToday = df.format(globalToday);
reportContext.setParameterValue("p_EDate", globalToday);
</pre>
<br />
Let me know if this works for you.
AlanC
Thanks Michael. You've come through again!
With a little tweak for UK time, that worked perfectly.
Thanks again.