Home > Articles > Home & Office Computing > Microsoft Applications

This chapter is from the book

This chapter is from the book

Formatting Numbers, Dates, and Times

One of the best ways to improve the readability of your worksheets is to display your data in a format that is logical, consistent, and straightforward. Formatting currency amounts with leading dollar signs, percentages with trailing percent signs, and large numbers with commas are a few of the ways you can improve your spreadsheet style.

This section shows you how to format numbers, dates, and times using Excel’s built-in formatting options. You’ll also learn how to create your own formats to gain maximum control over the appearance of your data.

Numeric Display Formats

When you enter numbers in a worksheet, Excel removes any leading or trailing zeros. For example, if you enter 0123.4500, Excel displays 123.45. The exception to this rule occurs when you enter a number that is wider than the cell. In this case, Excel usually expands the width of the column to fit the number. However, in some cases, Excel tailors the number to fit the cell by rounding off some decimal places. For example, a number such as 123.45678 is displayed as 123.4568. Note that, in this case, the number is changed for display purposes only; Excel still retains the original number internally.

When you create a worksheet, each cell uses this format, known as the General number format, by default. If you want your numbers to appear differently, you can select from among Excel’s seven categories of numeric formats: Number, Currency, Accounting, Percentage, Fraction, Scientific, and Special:

  • Number formats—The number formats have three components: the number of decimal places, whether the thousands separator (,) is used, and how negative numbers are displayed. For negative numbers, you can display the number with a leading minus sign, in red, surrounded by parentheses, or in red surrounded by parentheses.
  • Currency formats—The currency formats are similar to the number formats, except that the thousands separator is always used, and you have the option of displaying the numbers with a leading dollar sign ($) or some other currency symbol.
  • Accounting formats—With the accounting formats, you can select the number of decimal places and whether to display a leading dollar sign (or other currency symbol). If you do use a dollar sign, Excel displays it flush left in the cell. All negative entries are displayed surrounded by parentheses.
  • Percentage formats—The percentage formats display the number multiplied by 100 with a percent sign (%) to the right of the number. For example, .506 is displayed as 50.6%. You can display up to 14 decimal places.
  • Fraction formats—The fraction formats enable you to express decimal quantities as fractions. There are nine fraction formats in all, including displaying the number as halves, quarters, eighths, sixteenths, tenths, and hundredths.
  • Scientific formats—The scientific formats display the most significant number to the left of the decimal, 2–30 decimal places to the right of the decimal, and then the exponent. So, 123000 is displayed as 1.23E+05.
  • Special formats—The special formats are a collection designed to take care of special cases. Here’s a list of the special formats, with some examples:

Format

Enter This

It Displays as This

ZIP code

1234

01234

ZIP code + 4

123456789

12345-6789

Phone number

123456789

(123) 456-7890

Social Security number

123456789

123-45-6789

Changing Numeric Formats

The quickest way to format numbers is to specify the format as you enter your data. For example, if you begin a dollar amount with a dollar sign ($), Excel automatically formats the number as currency. Similarly, if you type a percent sign (%) after a number, Excel automatically formats the number as a percentage. Here are a few more examples of this technique. Note that you can enter a negative value using either the negative sign (–) or parentheses.

Number Entered

Number Displayed

Format Used

$1234.567

$1,234.57

Currency

($1234.5)

($1,234.50)

Currency

10%

10%

Percentage

123E+02

1.23E+04

Scientific

5 3/4

5 3/4

Fraction

0 3/4

3/4

Fraction

3/4

4–Mar

Date

Specifying the numeric format as you enter a number is fast and efficient because Excel guesses the format you want to use. Unfortunately, Excel sometimes guesses wrong (for example, interpreting a simple fraction as a date). In any case, you don’t have access to all the available formats (for example, displaying negative dollar amounts in red). To overcome these limitations, you can select your numeric formats from a list. Here are the steps to follow:

  1. Select the cell or range of cells to which you want to apply the new format.
  2. Select the Home tab.
  3. Pull down the Number Format list. Excel displays its built-in formats, as shown in Figure 3.13. Under the name of each format, Excel shows you how the current cell would be displayed if you chose that format.
  4. Figure 3-13

    Figure 3.13. In the Home tab, pull down the Number Format list to see all of Excel’s built-in numeric formats.

  5. Click the format you want to use.

For more numeric formatting options, use the Number tab of the Format Cells dialog box. Select the cell or range and then select Home, Number Format, More Number Formats. (You can also click the Number group’s dialog box launcher or press Ctrl+1.) As you can see in Figure 3.14, when you click a numeric format in the Category list, Excel displays more formatting options, such as the Decimal Places spin box. (The options you see depend on the category you select.) The Sample information box shows a sample of the format applied to the current cell’s contents.

Figure 3-14

Figure 3.14. When you select a format in the Category list, Excel displays the format’s options.

As an alternative to the Format Cells dialog box, Excel offers several keyboard shortcuts for setting the numeric format. Select the cell or range you want to format, and use one of the key combinations listed in Table 3.6.

Table 3.6. Shortcut Keys for Selecting Numeric Formats

Shortcut Key

Format

Ctrl+~

General

Ctrl+~

Number (two decimal places; using thousands separator)

Ctrl+$

Currency (two decimal places; using dollar sign; negative numbers surrounded by parentheses)

Ctrl+%

Percentage (zero decimal places)

Ctrl+^

Scientific (two decimal places)

You can use the controls in the Home tab’s Number group as another method of selecting numeric formats. The Number Format list (see Figure 3.14) displays all the formats. Here are the other controls that appear in this group:

Button

Format

Accounting Style

Accounting (two decimal places; using dollar sign)

Percent Style

Percentage (zero decimal places)

Comma Style

Number (two decimal places; using thousands separator)

Increase Decimal

Increases the number of decimal places in the current format

Decrease Decimal

Decreases the number of decimal places in the current format

Customizing Numeric Formats

Excel numeric formats give you lots of control over how your numbers are displayed, but they have their limitations. For example, no built-in format enables you to display a number such as 0.5 without the leading zero, or to display temperatures using, for example, the degree symbol.

To overcome these and other limitations, you need to create your own custom numeric formats. You can do this either by editing an existing format or by entering your own from scratch. The formatting syntax and symbols are explained in detail later in this section.

Every Excel numeric format, whether built-in or customized, has the following syntax:

  • positive format;negative format;zero format;text format

The four parts, separated by semicolons, determine how various numbers are presented. The first part defines how a positive number is displayed, the second part defines how a negative number is displayed, the third part defines how zero is displayed, and the fourth part defines how text is displayed. If you leave out one or more of these parts, numbers are controlled as shown here:

Number of Parts

Format Syntax Used

Three

positive format;negative format;zero format

Two

positive and zero format; negative format

One

positive, negative, and zero format

Table 3.7 lists the special symbols you use to define each of these parts.

Table 3.7. Numeric Formatting Symbols

Symbol

Description

General

Displays the number with the General format.

#

Holds a place for a digit and displays the digit exactly as typed. Displays nothing if no number is entered.

0

Holds a place for a digit and displays the digit exactly as typed. Displays 0 if no number is entered.

?

Holds a place for a digit and displays the digit exactly as typed. Displays a space if no number is entered.

. (period)

Sets the location of the decimal point.

,(comma)

Sets the location of the thousands separator. Marks only the location of the first thousand.

%

Multiplies the number by 100 (for display only) and adds the percent (%) character.

E+ e+ E– e–

Displays the number in scientific format. E– and e– place a minus sign in the exponent; E+ and e+ place a plus sign in the exponent.

/ (slash)

Sets the location of the fraction separator.

$ ( ) : – + <space>

Displays the character.

*

Repeats whatever character immediately follows the asterisk until the cell is full. Doesn’t replace other symbols or numbers.

_ (underscore)

Inserts a blank space the width of whatever character follows the underscore.

\ (backslash)

Inserts the character that follows the backslash.

"text"

Inserts the text that appears within the quotation marks.

@

Holds a place for text.

[COLOR]

Displays the cell contents in the specified color.

[COLORn]

Displays the cell contents in the specified color value (where n is a number between 1 and 56).

[condition value]

Uses conditional statements to specify when the format is to be used.

Before looking at some examples, let’s run through the basic procedure. To customize a numeric format, select the cell or range you want to format and then follow these steps:

  1. Select Home, Number Format, More Number Formats (or press Ctrl+1) and select the Number tab, if it’s not already displayed.
  2. In the Category list, click Custom.
  3. If you’re editing an existing format, select it in the Type list box.
  4. Edit or enter your format code.
  5. Click OK. Excel returns you to the worksheet with the custom format applied.

Excel stores each new format definition in the Custom category. If you edited an existing format, the original format is left intact and the new format is added to the list. You can select the custom formats the same way you select the built-in formats. To use your custom format in other workbooks, you copy a cell containing the format to that workbook. Figure 3.15 shows a dozen examples of custom formats.

Figure 3-15

Figure 3.15. Sample custom numeric formats.

Here’s a quick explanation for each example:

  • Example 1—These formats show how you can reduce a large number to a smaller, more readable one by using the thousands separator. A format such as 0,000.0 would display, for example, 12300 as 12,300.0. If you remove the three zeros between the comma and the decimal (to get the format 0,.0), Excel displays the number as 12.3 (although it still uses the original number in calculations). In essence, you’ve told Excel to express the number in thousands. To express a larger number in millions, you just add a second thousands separator.
  • Example 2—Use this format when you don’t want to display any leading or trailing zeros.
  • Example 3—These are examples of four-part formats. The first three parts define how Excel should display positive numbers, negative numbers, and zero. The fourth part displays the message “Enter a number” if the user enters text in the cell.
  • Example 4—In this example, the cents sign (¢) is used after the value. To enter the cents sign, press Alt+0162 on your keyboard’s numeric keypad. (This won’t work if you use the numbers along the top of the keyboard.) Table 3.8 shows some common ANSI characters you can use.

    Table 3.8. ANSI Character Key Combinations

    Key Combination

    ANSI Character

    Alt+0162

    ¢

    Alt+0163

    £

    Alt+0165

    ¥

    Alt+0169

    ©

    Alt+0174

    ®

    Alt+0176

    °

  • Example 5—This example adds the text string "Dollars" to the format.
  • Example 6—In this example, an M is appended to any number, which is useful if your spreadsheet units are in megabytes.
  • Example 7—This example uses the degree symbol (°) to display temperatures.
  • Example 8—The three semicolons used in this example result in no number being displayed (which is useful as a basic method for hiding a sensitive value).
  • Example 9—This example shows that you can get a number sign (#) to display in your formats by preceding # with a backslash (\).
  • Example 10—In this example, you see a trick for creating dot trailers. Recall that the asterisk (*) symbol fills the cell with whatever character follows it. So, creating a dot trailer is a simple matter of adding "*." to the end of the format.
  • Example 11—This example shows a similar technique that creates a dot leader. Here, the first three semicolons display nothing; then comes "*.", which runs dots from the beginning of the cell up to the text (represented by the @ sign).
  • Example 12—This example shows a format that’s useful for entering stock quotations.

Hiding Zeros

Worksheets look less cluttered and are easier to read if you hide unnecessary zeros. Excel enables you to hide zeros either throughout the entire worksheet or only in selected cells.

To hide all zeros, select File, Options, click the Advanced tab in the Excel Options dialog box, and scroll down to the Display Options for this Worksheet section. Clear the Show a Zero in Cells That Have Zero Value check box and then click OK.

To hide zeros in selected cells, create a custom format that uses the following format syntax:

positive format;negative format;

The extra semicolon at the end acts as a placeholder for the zero format. Because there’s no definition for a zero value, nothing is displayed. For example, the format $#,##0.00_);($#,##0.00); displays standard dollar values, but it leaves the cell blank if it contains zero.

Using Condition Values

The action of the formats you’ve seen so far have depended on whether the cell contents were positive, negative, zero, or text. Although this is fine for most applications, sometimes you need to format a cell based on different conditions. For example, you might want only specific numbers, or numbers within a certain range, to take on a particular format. You can achieve this effect by using the [condition value] format symbol. With this symbol, you set up conditional statements using the logical operators =, <, >, <=, >=, and <>, and the appropriate numbers. You then assign these conditions to each part of your format definition.

For example, suppose you have a worksheet for which the data must be within the range −1,000 and 1,000. To flag numbers outside this range, you set up the following format:

[>=1000]"Error: Value >= 1,000";[<=-1000]"Error: Value <= -1,000";0.00

The first part defines the format for numbers greater than or equal to 1,000 (an error message). The second part defines the format for numbers less than or equal to −1,000 (also an error message). The third part defines the format for all other numbers (0.00).

→ You’re better off using Excel’s extensive conditional formatting features; see “Applying Conditional Formatting to a Range,” p. 25.

Date and Time Display Formats

If you include dates or times in your worksheets, you need to make sure that they’re presented in a readable, unambiguous format. For example, most people would interpret the date 8/5/13 as August 5, 2013. However, in some countries, this date would mean May 8, 2013. Similarly, if you use the time 2:45, do you mean a.m. or p.m.? To avoid these kinds of problems, you can use Excel’s built-in date and time formats, listed in Table 3.9.

Table 3.9. Excel’s Date and Time Formats

Format

Display

m/d

8/3

m/d/yy

8/3/13

mm/dd/yy

08/03/13

d-mmm

3-Aug

d-mmm-yy

3-Aug-13

dd-mmm-yy

03-Aug-13

mmm-yy

Aug-13

mmmm-yy

August-13

mmmm d, yyyy

August 3, 2013

h:mm AM/PM

3:10 PM

h:mm:ss AM/PM

3:10:45 PM

h:mm

15:10

h:mm:ss

15:10:45

mm:ss.0

10:45.7

[h]:[mm]:[ss]

25:61:61

m/d/yy h:mm AM/PM

8/23/13 3:10 PM

m/d/yy h:mm

8/23/13 15:10

The [h]:[mm]:[ss] format requires a bit more explanation. You use this format when you want to display hours greater than 24 or minutes and seconds greater than 60. For example, suppose that you have an application in which you need to sum several time values (such as the time you’ve spent working on a project). If you add, say, 10:00 and 15:00, Excel normally shows the total as 1:00 (because, by default, Excel restarts times at 0 when they hit 24:00). To display the result properly (that is, as 25:00), use the format [h]:00.

You use the same methods you used for numeric formats to select date and time formats. In particular, you can specify the date and time format as you input your data. For example, entering Jan-07 automatically formats the cell with the mmm-yy format. Also, you can use the following shortcut keys:

Shortcut Key

Format

Ctrl+#

d—mmm—yy

Ctrl+@

h:mm AM/PM

Ctrl+;

Current date (m/d/yy)

Ctrl+:

Current time (h:mm AM/PM)

Customizing Date and Time Formats

Although the built-in date and time formats are fine for most applications, you might need to create your own custom formats. For example, you might want to display the day of the week (for example, Friday). Custom date and time formats generally are simpler to create than custom numeric formats. There are fewer formatting symbols, and you usually don’t need to specify different formats for different conditions. Table 3.10 lists the date and time formatting symbols.

Table 3.10. The Date and Time Formatting Symbols

Symbol

Description

Date Formats

d

Day number without a leading zero (1–31)

dd

Day number with a leading zero (01–31)

ddd

Three-letter day abbreviation (Mon, for example)

dddd

Full day name (Monday, for example)

m

Month number without a leading zero (1–12)

mm

Month number with a leading zero (01–12)

mmm

Three-letter month abbreviation (Aug, for example)

mmmm

Full month name (August, for example)

yy

Two-digit year (00–99)

yyyy

Full year (1900–2078)

Time Formats

h

Hour without a leading zero (0–24)

hh

Hour with a leading zero (00–24)

m

Minute without a leading zero (0–59)

mm

Minute without a leading zero (00–59)

s

Second without a leading zero (0–59)

ss

Second with a leading zero (00–59)

AM/PM, am/pm, A/P

Displays the time using a 12-hour clock

/ : . –

Symbols used to separate parts of dates or times

[COLOR]

Displays the date or time in the color specified

[condition value]

Uses conditional statements to specify when the format is to be used

Figure 3.16 shows some examples of custom date and time formats.

Figure 3-16

Figure 3.16. Sample custom date and time formats.

Deleting Custom Formats

The best way to become familiar with custom formats is to try your own experiments. Just remember that Excel stores each format you try. If you find that your list of custom formats is getting a bit unwieldy or that it’s cluttered with unused formats, you can delete formats by following the steps outlined here:

  1. Select Home, Number Format, More Number Formats.
  2. Click the Custom category.
  3. Click the format in the Type list box. (Note that you can delete only the formats you’ve created yourself.)
  4. Click Delete. Excel removes the format from the list.
  5. To delete other formats, repeat steps 2-4.
  6. Click OK. Excel returns you to the spreadsheet.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020