Pages

Thursday, January 16, 2014

1 Format Date with Date Picker
#startfloatingbox()
*Contents:* \\
#toc("2" "6" "false")
#endfloatingbox()
The default date picker in the Pentaho Report Designer, displays the date in the date-time format 'yyyy-MM-dd HH:mm:ss:SSS' by default. If you would like to change the way the selected date is displayed in the date picker, use 'Data Format' under the parameter definition. You can define, for example dd/MM/yyyy.
This will only change the display format on the date picker when the user makes a selection but not the value of the selected parameter.
Often, you will need to format the value of the parameter to match with the format in your database to be able to use the parameter in your SQL query. Here is one way to do it.
1.1 Implementation Steps
* Create another parameter (e.g. $Formatted)
* If you do not want this parameter to be displayed to the user, tick the box 'hidden'.
* Define the 'Post-Processing Formula'. You can use any formula expression there. For the given use case, we recommend to use the MESSAGE() function.
Here is a sample code that will format the date from 'yyyy-MM-dd HH:mm:ss:SSS' (defined in the parameter $today) to 'yyyy-MM-dd'.
{code:none}
=MESSAGE("{0,date,yyyy-MM-dd}"; [$today])
{code}
You can download a sample prpt file {attach:here|demoDateFormatting.prpt}
This is how your $Formatted parameter can be defined:
{image:Screenshot.png}

1.1  Download Sample
*You can download a sample prpt file {attach:here|demoDateFormatting.prpt}.*
1.1 Resources
* [Pentaho wiki>http://wiki.pentaho.com/display/COM/February+3%2C+2010+-+Pentaho+Reporting+3.6+overview+and+demo>_blank] - some videos on Report Designer

No comments:

Post a Comment