在Excel中,日期和时间在内部存储为数字。当您使用日期或时间格式格式化单元格时,这些仅会转换为清晰的日期和时间。下表列出了特定于日期和时间的格式代码。创建自定义显示格式(格式|单元格|数字选项卡|自定义)时,可以使用这些代码。

Symbol

Meaning

m

Displays the month or minutes as a number without a leading 0

mm

Displays the month or minutes as a number with a leading 0

mmm

Displays the month as abbreviated text (Jan, Feb, Mar, and so

on)

mmmm

Displays the month as text (January, February, March, and so

on)

d

Displays the day of the month as a number without a leading 0

dd

Displays the day of the month as a number with a leading 0

ddd

Displays the day of the week as abbreviated text (Sun, Mon,

Tue, and so on)

dddd

Displays the day of the week as text (Sunday, Monday, Tuesday,

and so on)

yy

Displays the year with two digits

yyyy

Displays the year with four digits

h

Displays the hour without a leading 0

hh

Displays the hour with a leading 0

s

Displays the seconds without a leading 0

ss

Displays the seconds with a leading 0

[ ]

When surrounding hours, minutes, or seconds place holders,

displays hours greater than 24 or minutes and seconds greater than 60

AM am PM pm A a P p

Uses a 12-hour clock, displaying AM or PM as

specified

\

Forces display of the following character

. (period)

The decimal point.

“text”

Displays the text within the quotes.

为了更好地理解日期和时间代码的效果,请查看以下信息,其中显示了几种常见的日期和时间格式以及它们如何影响数字。

Category

Format

Value

Displayed As

Date

m/d/yy

34369

2/4/94

d-mmm-yy

34409

16-Mar-94

Time

h:mm AM/PM

0.654166667

3:42 PM

[h]:mm:ss

2.592673611

62:13:27

请注意,这些示例的值列中显示的数字是Excel为日期和时间存储的内部值。

_ExcelTips_是您进行经济高效的Microsoft Excel培训的来源。

本技巧(2179)适用于Microsoft Excel 97、2000、2002和2003。可以在以下功能区中为Excel的功能区界面(Excel 2007及更高版本)找到本技巧的版本: