Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
scripted query and date parameter
Washu
Noob question - How do I use a scripted dynamic query with date parameter input text box? I have combed the forums and found much info on the topic but have been unable to produce desired results from the info. The goal is to present the user with 2 optional text boxes, one for start date and the other for end date. The query change is based on NULL values before opening the data set. I am attaching the report in case it is of any help. It does not throw error, but it doesn't query the given date either. Please help.
Whether tried as property binding or as script it seems to boil down to the input parameter getting changed from 2/1/07 to Feb 01, 2007 as a string. When the date parameter is defined as a string or date I don't have errors, but there is no filtering of the dates. When I set the param to datetime object I get the following:
Cannot get the result set metadata.
SQL statement does not return a ResultSet object.
SQL error #1: Line 1: Incorrect syntax near 'Feb'.
There has to be something silly I am not understanding here. Would someone please tell me what it is?
Find more posts tagged with
Comments
JasonW
Try something like:
if(params["startdate"].value != null && params["enddate"].value != null){
var sd = params["startdate"].value;
importPackage( Packages.java.text );
var sdf = new SimpleDateFormat("MM/dd/yyyy");
var sd = params["startdate"].value;
var fsd = sdf.format( sd );
this.queryText = this.queryText + " where ORDERDATE >= '" + fsd + "'";
}
Jason
Washu
Very appreciated Jason. That worked perfectly. Thanks to you, my report career does not end before it is started - yet.
ankit29
hi jason,
can you please tell me how can i pass date parameter through calendar.so that user can select start date and end date by just selecting dates from calendar.
thanks & Regards
ankit