How to format Dates and Numbers using Report info macro?

Purpose

How to format Dates and Numbers using Report info macro?

Answer

Date and time

Letter

Date

Examples

Letter

Date

Examples

G

Era designator

AD

y

Year

1996; 96

M

Month in year

July; Jul; 07

w

Week in year

27

W

Week in month

2

D

Day in year

189

d

Day in month

10

F

Day of week in month

2

E

Day in week

Tuesday; Tue

a

Am/pm marker

PM

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

m

Minute in hour

30

s

Second in minute

55

S

Millisecond

978

z

Time zone

Pacific Standard Time; PST; GMT-08:00

Z

Time zone

-0800

Examples:

Date and Time Pattern

Result

Date and Time Pattern

Result

yyyy/MMM/dd G 'at' HH:mm:ss z

2020/Dec/25 AD at 12:12:00 EST

EEE, dd/MMM/yyyy

Fri, 25/Dec/2020

h:mm a

12:12 PM

hh 'o''clock' a, zzzz

12 o'clock PM, Eastern Standard Time

yyyy.MMMMM.dd

2020.December.25

To find out more about date formatting, please refer to SimpleDateFormat documentation.

 

Numbers

Format

Description

Format

Description

0

A digit always will be displayed (if the number doesn't have enough digits, 0 will be displayed AKA zero padding)

#

A digit, (if the number doesn't have enough digits nothing will be displayed)

.

(period) Marks decimal separator

,

(comma) Marks thousand separator

%

Multiplies by 100 and shows number as percentage

X

Marks a character to be used in number prefix or suffix

'

(single quote) Marks a quote around special characters in prefix or suffix of formatted number.

Examples:

Pattern

Input

Formatted output

Pattern

Input

Formatted output

###.###

12.3

12.3

###.00

12.3

12.30

###,###.##

123456789.012

123,456,789.01

###.0#

123456.789

123456.79

##0.###

.123456

0.123

% ###,###.00

25.5

% 2,550.00

'%' ###,###.00

25.5

% 25.50

 

To find out more about number formatting, please refer to the DecimalFormat documentation.

Â