Jump to content

Query run with parameters


faisal007

Recommended Posts

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

If I am following you correctly what you would do is this:

 

where columnDate >= $P{someDate} and columnDate <= ${someDate}

 

Of course this is for a range. If you are doing = and the date is a "dateTime" variable you will have to consider the time stamp with in that variable. Otherwise, you can substring it to test just the date.

 

Calvin

Link to comment
Share on other sites

Hi!

Sorry, you missed a "P" there ...

Code:

where columnDate >= $P{someDate} and columnDate <= $P{someDate}

alternatively (at least, most database systems suport this)

Code:
[code]
where columnDate between $P{FromDate} and $P{ToDate}

 

Then, you define FromDate and ToDate as parameters (view->parameters in ireport) of type java.util.Date, give them some sensible default values, e.g.,

Code:
[code]
new java.util.Date()
new java.util.Date(0)
new java.util.Date(new java.util.Date()-1000l*3600*24)

 

Hope this helps,

Sebastian

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...