我正在创建一个参数为datetrfrom
和datetrto
的jasper报告。
过滤进行顺利,除非两个参数携带相同的数据,如
datetrfrom>= '15-12-2012'
datetrto<= '15-12-2012'
在15-12-2012处理的数据不会出来。
我在JSP中试过这个:
function ShowReport(){
var param='';
var timestart = ' 00:00:00'
var timeend = ' 23:59:59'
var datetrFrom = document.forms['report']['datetransfrom'].value;
datetrFrom.split("-")
//i split n join back the date to change the format from dd-MM-yyyy to yyyy-MM-dd
var dtf = [datetrFrom[6],datetrFrom[7],datetrFrom[8],datetrFrom[9],datetrFrom[5],datetrFrom[3],datetrFrom[4],datetrFrom[2],datetrFrom[0],datetrFrom[1] ].join('')
datetrfr = dtf + timestart; //i join the date with the timestart to create format yyyy-MM-dd hh:mm:ss
var datetrTo = document.forms['report']['datetransto'].value;
datetrTo.split("-")
var dtt = [datetrTo[6],datetrTo[7],datetrTo[8],datetrTo[9],datetrTo[5],datetrTo[3],datetrTo[4],datetrTo[2],datetrTo[0],datetrTo[1] ].join('')
datetrto = dtt + timeend; //i join the date with the timeend to create format yyyy-MM-dd hh:mm:ss
param = param + '@@dtTFrom=='+datetrfr+'@@dtTTo=='+datetrto;
@@dtTFrom
和@@dtTTo
是我在jasper报告中使用的参数。
这就是我在jasper报告中的where子句中所做的:
where record_line_status='NO'
and datetime_process >= convert(date, $P{dtTFrom},105)
and datetime_process <= convert(date, $P{dtTTo},105)
但是我的报告仍然不起作用。任何人都可以帮助我吗?
答案 0 :(得分:0)
我在这里解决了我的问题。 这是我在JSP中的新编码:
function ShowReport(){
var param='';
var timestart = ' 00:00:00'
var timeend = ' 23:59:59'
var orgFrom = document.forms['report']['org_id'].value;
param = param + 'orgFrom=='+orgFrom;
var datetrFrom = document.forms['report']['datetransfrom'].value;
var datefromsplit = datetrFrom.split('-');
var datefromjoin = [datefromsplit[2], datefromsplit[1], datefromsplit[0]].join('-');
var datefromsend = datefromjoin + timestart;
var datetrTo = document.forms['report']['datetransto'].value;
var datetosplit = datetrTo.split('-');
var datetojoin = [datetosplit[2], datetosplit[1], datetosplit[0]].join('-');
var datetosend = datetojoin + timeend;
param = param + '@@dtTFrom=='+datefromsend+'@@dtTTo=='+datetosend;
这就是我在jasper报告中的where子句中所做的:
where ep_lpp04_temp.record_line_status='No'
and EP_LPP04_TEMP.datetime_process >= convert(datetime, $P{dtTFrom}, 120)
AND EP_LPP04_TEMP.datetime_process <= convert(datetime, $P{dtTTo}, 120)
我的参数类是
java.lang.string