Converting TimestampRange to Timestamp

Posted on by By Nikhilesh, in Business Intelligence, Jaspersoft, Open Source Business Intelligence | 0

Converting TimestampRange to Timestamp with default value expression and passing it into the Dataset

Here when we are using our parameter class as

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



we will get error.

Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.

Lets Start 30 Days Free Trail

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

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments