specifying default date format/ value to Date

1

Hi,

I am new to Jasper Reports, using iReport. Want to know how to specify default value to Date? Also want default date format.

Thanks in advance..

shraddha.s.mirashi's picture
Joined: Apr 18 2013 - 11:40pm
Last seen: 5 years 10 months ago
Maybe you should try this, create a style in report and mark it as default, set the property "Pattern" to what you want.
hawkx - 6 years 3 months ago

3 Answers:

1

Maybe you should try this, create a style in report and mark it as default, set the property "Pattern" to what you want.

hawkx's picture
40
Joined: Nov 26 2012 - 7:34pm
Last seen: 1 year 5 months ago

Thank you for ur reply. Actually i want to this parameter in query. And if i set its default value as '01/01/2013', i get ClassCastException. So i want to know what exact format it expects.

shraddha.s.mirashi - 6 years 3 months ago
0

Hi 

I think you need to find the date format supported by your datasource database.

Example: Oracle: '30-April-2013'

 

ajinkya_c's picture
976
Joined: Aug 29 2012 - 6:13am
Last seen: 2 years 4 months ago
0
 I can't find any way to do this directly, but here's a workaround:

1) First make the parameter's type String rather than Date.

2) Then enter a Default value expression for the date literal like this: "2018-01-23"

3) Finally, use something like the following, which might need to get adjusted for the type of SQL you're using:

  • For MariaDB (or MySQL) SQL use: STR_TO_DATE($P{From},"%Y-%m-%d"), where you need to first replace 'From' with the name of your actual parameter.

This allows you to easily edit the default value as a string, and then use it as a date type in your SQL.

Create's picture
89
Joined: May 23 2018 - 10:12pm
Last seen: 4 months 2 days ago
Feedback
randomness