specifying default date format/ value to Date

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: 9 years 8 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 - 10 years 1 month ago

3 Answers:

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
428
Joined: Nov 26 2012 - 7:34pm
Last seen: 5 years 4 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 - 10 years 1 month ago

Hi 

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

Example: Oracle: '30-April-2013'

 

ajinkya_c's picture
6341
Joined: Aug 29 2012 - 6:13am
Last seen: 6 years 2 months ago
 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
465
Joined: May 23 2018 - 10:12pm
Last seen: 4 years 2 months ago
Feedback
randomness