To use IBM Cognos product documentation, you must enable JavaScript in your browser.

Using Patterns to Format Data

You can format data so that it matches any pattern of text and numbers when default formats are not appropriate. For example, you can format dates to use full text including the era, or you can format them to only use numbers and show the last two digits of years to save space.

Using symbols and patterns can provide similar results as basic data formatting tasks. For example, you can set how many digits appear after the decimal point. You can achieve these types of results with a pattern, or you can set the No. of Decimal Places property. Patterns allow flexibility for more complex requirements.

Each supported content language code requires a specific set of symbols to be used in patterns. For each language code, there are two tables you will need; one for date and time symbols, and one for decimal symbols. The decimal symbols are the same for all locales, however, date and time symbols are grouped into six locale groups. Check the Date and Time Symbol section to see which locale group is used for your locale.

To define patterns, open the Data Format dialog box, and edit the Pattern property for each format type. Use the symbols that are defined in the language code tables, and follow these guidelines.

Pattern Guidelines

When you define a pattern, the number of symbols you use affects how the data will be shown. There are different rules for text, numbers, and values that can take the form of text or numbers.

Text

You can specify whether text is produced in full or abbreviated form.

Number of symbols

Meaning

Example

4 or more

Full text form

EEEE produces Monday

Less than 4

Abbreviated form

EEE produces Mon

Numbers

The number of symbols you use in a pattern sets the minimum number of digits that are produced in a report. Numbers that have fewer digits than specified are zero-padded. For example, if you specify mm for minutes, and the database value is 6, the report will show 06.

Note: The year value is handled differently. If you specify two symbols for year, the last two digits of the year value is produced. For example, yyyy produces 1997, and yy produces 97.

Text and Numbers

For values that can produce text or numbers, such as months, you can specify whether text or numbers are produced, and whether words are abbreviated.

Number of symbols

Meaning

Example

3 or more

Text

MMMM produces January

MMM produces Jan

Less than 3

Numbers

MM produces 01

M produces 1

Date and Time Symbols

Date and time symbols are divided into locales, each of which is detailed below.

Locale Group A

Locales: af-za, en, en-au, en-be, en-bw, en-ca, en-gb, en-hk, en-ie, en-in, en-mt, en-nz, en-ph, en-sg, en-us, en-vi, en-za, fo-fo, gl-es, id, id-id, is, is-is, it, it-ch, it-it, kk-kz, ms, ms-bn, ms-my, nb-no, nl, nl-be, nl-nl, no, no-no, om-et, om-so, pl, pl-pl, pt, pt-br, pt-pt, so-dj, so-et, so-ke, so-so, sv, sv-fi, sv-se, sw-ke, sw-tz

Meaning

Symbol

Presentation

Example

Era

G

Text

AD

Year

y

Number

1996

Year (of 'Week of Year')

Y

Number

1996

Month in year

M

Text and number

July and 07

Week in year

w

Number

27

Week in month

W

Number

2

Day in year

D

Number

189

Day in month

d

Number

10

Day of week in month

F

Number

2 (2nd Wed in July)

Day of Week (1=first day)

e

Number

2

Day in week

E

Text

Tuesday

a.m. or p.m. marker

a

Text

pm

Hour in day (1 to 24)

k

Number

24

Hour in a.m. or p.m. (0 to 11)

K

Number

0

Hour in a.m. or p.m. (1 to 12)

h

Number

12

Hour in day (0 to 23)

H

Number

0

Minute in hour

m

Number

30

Second in minute

s

Number

55

Millisecond

S

Number

978

Time zone

z

Text

Pacific Standard Time

Escape used in text

'

n/a

n/a

Single quote

''

n/a

'

Locale Group B

Locales: be-by, bg-bg, el, el-gr, fi, fi-fi, hr, hr-hr, hu, hu-hu, ja, ja-jp, ko, ko-kr, ro, ro-ro, ru, ru-ua, ru-ru, sh-yu, sk, sk-sk, sl-si, sq-al, sr-sp, th, tr, tr-tr, uk-ua, zh, zh-cn, zh-hk, zh-mo, zh-sg, zh-tw

Meaning

Symbol

Presentation

Example

Era

G

Text

AD

Year

a

Number

1996

Year (of 'Week of Year')

A

Number

1996

Month in year

n

Text and number

July and 07

Week in year

w

Number

27

Week in month

W

Number

2

Day in year

D

Number

189

Day in month

j

Number

10

Day of week in month

F

Number

2 (2nd Wed in July)

Day of Week (1=first day)

e

Number

2

Day in week

E

Text

Tuesday

a.m. or p.m. marker

x

Text

pm

Hour in day (1 to 24)

h

Number

24

Hour in a.m. or p.m. (0 to 11)

K

Number

0

Hour in a.m. or p.m. (1 to 12)

k

Number

12

Hour in day (0 to 23)

H

Number

0

Minute in hour

m

Number

30

Second in minute

s

Number

55

Millisecond

S

Number

978

Time zone

z

Text

Pacific Standard Time

Escape used in text

'

n/a

n/a

Single quote

''

n/a

'

Locale Group C

Locales: ca-es, cs, cs-cz, da, da-dk, es, es-ar, es-bo, es-cl, es-co, es-cr, es-do, es-ec, es-es, es-gt, es-hn, es-mx, es-ni, es-pa, es-pe, es-pr, es-py, es-sv, es-us, es-uy, es-ve, eu-es, mk-mk

Meaning

Symbol

Presentation

Example

Era

G

Text

AD

Year

u

Number

1996

Year (of 'Week of Year')

U

Number

1996

Month in year

M

Text and number

July and 07

Week in year

w

Number

27

Week in month

W

Number

2

Day in year

D

Number

189

Day in month

t

Number

10

Day of week in month

F

Number

2 (2nd Wed in July)

Day of Week (1=first day)

e

Number

2

Day in week

E

Text

Tuesday

a.m. or p.m. marker

a

Text

pm

Hour in day (1 to 24)

h

Number

24

Hour in a.m. or p.m. (0 to 11)

K

Number

0

Hour in a.m. or p.m. (1 to 12)

k

Number

12

Hour in day (0 to 23)

H

Number

0

Minute in hour

m

Number

30

Second in minute

s

Number

55

Millisecond

S

Number

978

Time zone

z

Text

Pacific Standard Time

Escape used in text

'

n/a

n/a

Single quote

''

n/a

'

Locale Group D

Locales: de, de-at, de-be, de-ch, de-de, de-lu

Meaning

Symbol

Presentation

Example

Era

G

Text

AD

Year

j

Number

1996

Year (of 'Week of Year')

J

Number

1996

Month in year

M

Text and number

July and 07

Week in year

w

Number

27

Week in month

W

Number

2

Day in year

D

Number

189

Day in month

t

Number

10

Day of week in month

F

Number

2 (2nd Wed in July)

Day of Week (1=first day)

e

Number

2

Day in week

E

Text

Tuesday

a.m. or p.m. marker

a

Text

pm

Hour in day (1 to 24)

h

Number

24

Hour in a.m. or p.m. (0 to 11)

K

Number

0

Hour in a.m. or p.m. (1 to 12)

k

Number

12

Hour in day (0 to 23)

H

Number

0

Minute in hour

m

Number

30

Second in minute

s

Number

55

Millisecond

S

Number

978

Time zone

z

Text

Pacific Standard Time

Escape used in text

'

n/a

n/a

Single quote

''

n/a

'

Locale Group E

Locales: fr, fr-be, fr-ca, fr-ch, fr-fr, fr-lu

Meaning

Symbol

Presentation

Example

Era

G

Text

AD

Year

a

Number

1996

Year (of 'Week of Year')

A

Number

1996

Month in year

M

Text and number

July and 07

Week in year

w

Number

27

Week in month

W

Number

2

Day in year

D

Number

189

Day in month

j

Number

10

Day of week in month

F

Number

2 (2nd Wed in July)

Day of Week (1=first day)

e

Number

2

Day in week

E

Text

Tuesday

a.m. or p.m. marker

x

Text

pm

Hour in day (1 to 24)

h

Number

24

Hour in a.m. or p.m. (0 to 11)

K

Number

0

Hour in a.m. or p.m. (1 to 12)

k

Number

12

Hour in day (0 to 23)

H

Number

0

Minute in hour

m

Number

30

Second in minute

s

Number

55

Millisecond

S

Number

978

Time zone

z

Text

Pacific Standard Time

Escape used in text

'

n/a

n/a

Single quote

''

n/a

'

Locale Group F

Locales: ga-ie

Meaning

Symbol

Presentation

Example

Era

R

Text

AD

Year

b

Number

1996

Year (of 'Week of Year')

B

Number

1996

Month in year

M

Text and number

July and 07

Week in year

t

Number

27

Week in month

T

Number

2

Day in year

l

Number

189

Day in month

L

Number

10

Day of week in month

F

Number

2 (2nd Wed in July)

Day of Week (1=first day)

e

Number

2

Day in week

E

Text

Tuesday

a.m. or p.m. marker

a

Text

pm

Hour in day (1 to 24)

u

Number

24

Hour in a.m. or p.m. (0 to 11)

K

Number

0

Hour in a.m. or p.m. (1 to 12)

k

Number

12

Hour in day (0 to 23)

U

Number

0

Minute in hour

n

Number

30

Second in minute

s

Number

55

Millisecond

S

Number

978

Time zone

c

Text

Pacific Standard Time

Escape used in text

'

n/a

n/a

Single quote

''

n/a

'

Decimal Format Symbols

All locales

Symbol

Meaning

0

A digit that is shown even if the value is zero.

#

A digit that is suppressed if the value is zero.

.

A placeholder for decimal separator.

,

A placeholder for thousands grouping separator.

E

Separates mantissa and exponent for exponential formats.

;

Separates formats for positive numbers and formats for negative numbers.

-

The default negative prefix.

%

Multiplied by 100, as percentage.

 

Multiplied by 1000, as per mille.

 

The currency symbol. If this symbol is present in a pattern, the monetary decimal separator is used instead of the decimal separator.

 

The international currency sign. It will be replaced by an international currency symbol. If it is present in a pattern, the monetary decimal separator is used instead of the decimal separator.

X

Other characters that can be used in the prefix or suffix.

'

Used to quote special characters in a prefix or suffix.

/u221E

Infinity symbol.

/uFFFD

Not a Number symbol.