Report Studio also enables you to specify a custom format for numeric, date‑and‑time and string data, in cases when the available standard formats do not meet your requirements. To apply a custom format to data, you specify a format pattern.
Applying a custom number format
You can define a custom number format using special symbols to construct a format pattern. A format pattern shows places held by the currency symbol and the thousands and decimal separators. The thousands separator and the decimal separator are locale‑dependent. In the English (United States) locale, for example, a comma separates thousands places, and a period separates decimal places. In most European locales, a space separates thousands places, and a comma separates decimal places. Table 6‑3 lists example results of custom number format patterns.
Table 6‑3 Results of custom number formats
Format pattern
Data in original format
Result of formatting
0000.00
12.5 124.5 1240.553
0012.50 0124.50 1240.55
#.000
100 100.25 100.2567
100.000 100.250 100.257
$#,###
2000.00 20000.00
$2,000 $20,000
ID #
15
ID 15
Applying a custom date-and-time format
You can define a custom date‑and‑time format using special symbols to construct a format pattern. Use custom date formatting only for reports that are viewed in a single locale. Custom formats always display dates in the format you set. This format can be inappropriate for other locales. For example, if you use the format MM‑dd‑yy, the date January 10, 2006, always appears as 01‑10‑06, regardless of the locale in which the report is viewed. For locales in which dates customarily appear in day‑month‑year format, the date 01‑10‑06 is interpreted as October 1, 2006.
Table 6‑4 lists the specials symbols used to define custom date‑and‑time formats.
Table 6‑4 Symbols for defining custom date‑and‑time formats
Symbol
Description
Example
yy
Short year
08
yyyy
Long year
2008
MM
Month as a number
07
MMM
Short month name
Jul
MMMM
Full month name
July
d
Day in month
10
W
Week in month
2
w
Week in year
28
DD
Day in year
192
E
Short day of week
Thu
EEEE
Long day of week
Thursday
H
Hour in day (0 ‑ 23)
0
k
Hour in day (1 ‑ 24)
24
K
Hour in AM/PM (0 ‑ 11)
0
h
Hour in AM/PM (1 ‑ 12)
12
mm
Minutes
30
ss
Seconds
55
a
AM or PM
8:00:00AM
Table 6‑5 shows examples of custom formats and their effects on a date that is stored as April 15, 2006 12:15:30 PM.
Table 6‑5 Examples of custom date‑and‑time formats
Format pattern
Result of formatting
MM‑dd‑yy
04‑15‑06
E, M/d/yyyy
Fri, 4/15/2006
MMM d
Apr 15
MMMM
April
yyyy
2006
W
3 (the week in the month)
w
15 (the week in the year)
DD
105 (the day in the year)
h:mm:ss
12:15:30
Applying a custom string format
You can define a custom string format using special symbols to construct a format pattern. Table 6‑6 describes these symbols.
Table 6‑6 Symbols for defining custom string formats
Symbol
Description
@
Character placeholder. Each @ character displays a character in the string. If the string has fewer characters than the number of @ symbols that appear in the format pattern, spaces appear. Placeholders are filled from right to left, unless you specify an exclamation point (!) at the beginning of the format pattern.
&
Same as @, except if the string has fewer characters, spaces do not appear.
!
Specifies that placeholders are to be filled from left to right.
>
Converts string characters to uppercase.
<
Converts string characters to lowercase.
Table 6‑7 shows example results of custom string format patterns on string data.