converting date parameter to simpledate format usi

2019-05-11 00:06发布

问题:

I have a startDate and an endDate as an input parameters. This parameters are used in the query say:

SELECT * FROM patientRecords 
WHERE patientRecords.dateOfdischarge BETWEEN $P{startDate} AND $P{endDate} 

Now, since the startDate and endDate are the parameters which are passed to the JasperReports.

I have to ensure that they are in mm/dd/yyyy Date format.

How do I go about converting the input parameter to this format using iReport?

回答1:

U can try change the patern from propertise>textfield propertise or u can try this to_char(tablename.fieldname, 'mm/dd/yyyy') as fieldname



回答2:

Try this format it will work if you are using Mysql database

date_column_name between date_format($P{start_date},'%Y-%m-%d') and date_format($P{end_date},'%Y-%m-%d') date_column_name between date_format($P{start_date},'%Y-%m-%d') and date_format($P{end_date},'%Y-%m-%d')



回答3:

If I were you, I'll directly send these parameters as in the format you said from Java. If that not possible for you and wanna be sure, you can use EL for formatting as well such as Java or Groovy in the iReport