Converting TimestampRange to Timestamp with default value expression and passing it into the Dataset
Here when we are using our parameter class as net.sf.jasperreports.types.date.TimestampRange
with default value expression like
new java.sql.Timestamp((new Date()).getYear(), (new Date()).getMonth(),1,0,0,0,0)
then it will return (2016-01-01 00:00:00) format / Year /Month / Week/ Day.
new java.sql.Timestamp((new java.sql.Timestamp((new Date()).getYear(), (new Date()).getMonth(),(new Date()).getDate(),0,0,0,0)).getTime() + 86399000)
then it will return(2016-01-01 23:59:59) format / Year /Month / Week/ Day.
In this casse the default value will be in timestamp format so while extracting date from date range parameter
$P{P_StartDate}.getStart()
$P{P_EndDate}.getEnd()
we will get error.
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
So in this case we can get this timestamp format date in the variable of ireport or jasperstudio
we can create a variable and pass it to the SubDataset parameter by maping the variable of main report to subdataset or subreport and there we can use this timestamp value and pass it to our Query.
Sql Query passing in jasper
column between $P{P_StartDate} and $P{P_EndDate}
If there are no default date ranges then we can pass a
$X{[BETWEEN], column, startParam, endParam}
If you want to set a relative date as a default value expression of a JasperReports parameter, use the following relative date-builder pattern:
- new DateRangeBuilder(“DAY-1”).toDateRange()
- new DateRangeBuilder(“WEEK”).set(Timestamp.class).toDateRange()
- new DateRangeBuilder(“2016-01-01”).toDateRange()
- new DateRangeBuilder(“2016-01-01 12:34:56”).toDateRange();
Best Open Source Business Intelligence Software Helical Insight is Here
A Business Intelligence Framework
Thanks & Regards,
Prasanth Kumar
Can we convert date to timestamp Converting TimestampRange to Timestamp Date and Time Functions and Operators How do I convert a timestamp How do I get timestamp from time zone iReports jasper server jasper studio What is timestamp format with T and Z