mulcamd Posted July 10, 2011 Share Posted July 10, 2011 In my database, all dates are in seconds since 01-01-2001.To have the user select an date I use an input control of the type date.So after the user selects a date, this data parameter has to be converted from date to long and as long be used in the sql where.In the query I use a second paramter of the type long. But this one seems to be always "null"How to do that?? What I did was: 1e parameter: parameter is named $P{startDate}, type java.util.DateThis paramter is used in the input control.2e parameter startDateLong, type java.lang.Long and "Default Value Expression" as $P{startDate}.getTime() / 1000L Link to comment Share on other sites More sharing options...
jmurray Posted July 12, 2011 Share Posted July 12, 2011 The problem is that $P{startDate} is not defined when you try to set the default value of $P{startDate}.getTime() / 1000L to parameter startDateLong. Use a variable instead, and use BigDecimal rather than Integer: <variable name="startDateBD" class="java.math.BigDecimal"> <variableExpression><![CDATA[new java.math.BigDecimal($P{startDate}.getTime() / 1000)]]></variableExpression> <initialValueExpression><![CDATA[new java.math.BigDecimal(0)]]></initialValueExpression> </variable> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now