How to get last date of the month in Jasper Report date parameter input control? -
i working on jasper report using ireport , in taking 2 input dates start_date , end_date user.
now want end_date should last date of month start_date. searched on internet couldn't write/get condition can write in default expression end_date parameter.
can please suggest me way this?
i tried sql query additional parameter date_diff retrieve data 1 month only. sql query looks this:
select ead_pgm_cash_sw, ead_pgm_fs_sw, ead_pgm_mcl_sw,count(*) cnt ead_case a, ead_program b a.unique_trace_hi = b.to_ead_case_lnk_hi , a.unique_trace_lo = b.to_ead_case_lnk_lo , a.ead_case_id = b.ead_pgm_case_num , a.ead_cs_batch_dt >= $p{start_date} , a.ead_cs_batch_dt <= $p{end_date} , $p{start_date}< $p{end_date} , $p{date_diff} <= 30 , (b.ead_pgm_cash_sw, b.ead_pgm_fs_sw, b.ead_pgm_mcl_sw) in (('n','y','n'),('y','y','y'),('n','n','y'),('n','y','y'),('y','n','y'), ('y','n','n')) group ead_pgm_cash_sw, ead_pgm_fs_sw, ead_pgm_mcl_sw order ead_pgm_cash_sw, ead_pgm_fs_sw, ead_pgm_mcl_sw
but way not proper. want using expression in "default value expression" field in ireport.
have blog - date calculation in ireport.
i have tried , working fine. here jasper file-
<?xml version="1.0" encoding="utf-8"?> <jasperreport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" language="groovy" pagewidth="595" pageheight="842" whennodatatype="allsectionsnodetail" columnwidth="555" leftmargin="20" rightmargin="20" topmargin="20" bottommargin="20" uuid="d6133c1e-7de4-4386-9c92-a6c4f7cece05"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="cal" class="java.util.calendar" isforprompting="false"> <defaultvalueexpression><![cdata[calendar.getinstance()]]></defaultvalueexpression> </parameter> <parameter name="ldate" class="java.util.date" isforprompting="false"> <defaultvalueexpression><![cdata[( $p{cal}.set(new date().getyear()+1900, new date().getmonth(), new date().getdate()) || $p{cal}.set(calendar.day_of_month, $p{cal}.getactualmaximum(calendar.day_of_month)) ) ? null : $p{cal}.gettime()]]></defaultvalueexpression> </parameter> <columnheader> <band height="46" splittype="stretch"> <textfield> <reportelement x="127" y="0" width="291" height="46" uuid="bb060132-5aa4-4a75-817a-650f672c707c"/> <textfieldexpression><![cdata[$p{ldate}]]></textfieldexpression> </textfield> </band> </columnheader> </jasperreport>
note - have used new date()
testing.
Comments
Post a Comment