Patterns can be applied to format values of number and date parameters. While designing your report, you may need to display such parameters in various formats, e.g. a contract date in short and in full date format.
In this tutorial you will learn to:
•Use number and date pattern syntax
•Apply a pattern to a parameter
•Apply a pattern as print setting
•Apply a pattern for parameter in expression
1. Use number and date pattern syntax
When applying a pattern to a parameter or a print setting ReportBro offers a predefined set of patterns to choose from. However, you are not limited to these but you may also use your own patterns. We'll explain the most commonly used patterns with examples - if you'd like to go into more detail take a look at Number Pattern Syntax and Date Pattern Syntax for a complete reference on what patterns you may apply.
Example date/time pattern test data: 2024-01-28 14:00 |
Result
|
M/d/yyyy |
1/28/2024 omits leading zero for day and month |
EEE, MMM d, yyyy |
Sun, Jan 28, 2024 get abbreviations with 1-3 characters |
EEEE - MMMM d, yyyy |
Sunday - January 28, 2024 get full name with 4 characters |
h:mm a |
2:00 PM 'h' represents hour 1-12 - use in combination with 'a' to show AM or PM |
H:mm |
14:00 'H' represents hour 0-23 |
Example number pattern test data: 1000.4444 |
Result
|
#,##0 |
1,000 Show thousand separator, cut decimals |
0.0 |
1000.4 Show exactly one decimal |
0.## |
1000.44 Show maximum of 2 decimals |
#,##0.00 $ |
1,000.44 € Show currency sign according to document property setting after number |
0.00 % |
100044.44 % Multiply by 100 and show as percentage |
2. Apply a pattern to a parameter
The direct application of a pattern serves as a fallback when this parameter is used in the report and no other pattern is applied.
3. Apply a pattern as print setting
Applying a pattern in the print setting of a text or table content element overrides the parameter pattern.
4. Apply a pattern for parameter in expression
An expression allows to format a specific parameter directly with a given pattern. The formatted value is then returned as a string.
Use this method if you need to insert multiple parameters into a text element with patterns that do not match the pattern set for the parameter.