Dancing With Data
Dancing With Data
1. In a new worksheet, enter the average number of defects per day (25) in
a cell.
10. In the cell below, enter a formula that multiplies the number of working
days per month (22) by the result just calculated with the POISSON.DIST
function.
11. If desired, enter a label in an adjacent cell to identify this as the number
of days per month you can expect to have 20 or fewer defects.
FIGURE 11-12:
Using the
POISSON.DIST
function to
calculate a
cumulative
probability.
Master dates.
Calculate time.
Chapter 12
Dressing Up for Date
Functions
O
ften, when working with Excel, you need to manage dates. Perhaps you
have a list of dates when you visited a client and need to count how many
times you were there in September. On the other hand, maybe you are
tracking a project over a few months and want to know how many days are in
between the milestones.
Excel has a number of useful Date functions to make your work easier! This
chapter explains how Excel handles dates, how to compare and subtract dates,
how to work with parts of a date (such as the month or year), and even how to
count the number of days between two dates. You can always reference the current
data from your computer’s clock and use it in a calculation; I show you how.
Because Excel represents dates in this way, it can work with dates in the same
manner as numbers. For example, you can subtract one date from another to find
out how many days are between them. Likewise, you can add 14 to today’s date to
get a date two weeks in the future. This trick is very useful, but people are used to
seeing dates represented in traditional formats, not as numbers. Fortunately,
Excel uses date serial numbers only behind the scenes, and what you see in your
workbook are dates in the standard date formats such as Jan 20, 2018 and 1/20/18.
In Excel for the Mac, the serial numbering system begins on January 1, 1904.
The way years are handled requires special mention. When a year is fully displayed
in 4 digits, such as 2018, there is no ambiguity. However, when a date is written in
a shorthand style, such as in 3/1/02, it isn’t clear what the year is. It could be 2002
or it could be 1902. Suppose that 3/1/02 is a shorthand entry for someone’s
birthday. On March 1, 2005, he is either 3 years old or 103 years old. In those coun-
tries that write dates as dd/mm/yy, this would be January 3, 1902 or January 3,
2002.
Excel and the Windows operating system have a default way of interpreting short-
hand years. Windows has a setting in the Customize Regional Options dialog box
located in the Control Panel. This setting guides how Excel interprets years. If the
setting is 1930 through 2029, 3/1/18 indicates the year 2018, but 3/1/45 indicates
the year 1945, not 2045. Figure 12-1 shows this setting.
1. Use the Windows search feature to find and open Control Panel.
3. Select Region.
FIGURE 12-1:
Setting how years
are interpreted in
the Customize
Format
dialog box.
To ensure full accuracy when working with dates, always enter the full 4 digits for
the year.
Formatting Dates
When you work with dates, you probably need to format cells in your worksheet.
It’s great that Excel tells you that June 1, 2018, is serially represented as 43252, but
you probably don’t want that in a report. To format dates, you use the Format
Cells dialog box, shown in Figure 12-2.
1. If it’s not already displayed, click the Home tab at the top of the Excel
screen.
2. Click the small arrow at the bottom-right corner of the Number section.
The Format Cells dialog box appears, revealing the Number tab.
FIGURE 12-2:
Using the Format
Cells dialog box
to control how
dates are
displayed.
Now you can turn the useful but pesky serial dates into a user-friendly format.
When you enter a date in a cell using one of the standard date formats, Excel rec-
ognizes it as a date and automatically assigns a Date format to the cell. You may
want to use the Number tab in the Format Cells dialog box to assign a different
Date format.
The DATE function combines individual day, month, and year components into a
single usable date. This makes using and referencing dates in your worksheet
easy. Follow along to use the DATE function:
5. Click the cell that has the number (1–12) that represents the month.
7. Click the cell that has the number (1–31) that represents the day of
the month.
Figure 12-3 displays a fourth column of dates that were created by using DATE and
the values from the first three columns. The fourth column of dates has been for-
matted so the dates are displayed in a standard format, not as a raw date serial
number.
FIGURE 12-3:
Using the DATE
function to
assemble a date
from separate
month, day, and
year values.
DATE provides some extra flexibility with the month number. Negative month
numbers are subtracted from the specified year. For example, the function
=DATE(2018, -5, 15) returns the date July 15, 2017, because July 2017 is 5 months
before the first month of 2018. Numbers greater than 12 work the same way.
=DATE(2018, 15, 1) returns March 1, 2019, because March 2019 is 15 months
after the first month of 2018.
Day numbers work the same way. Negative day numbers are subtracted from the
first of the specified month, and numbers that are greater than the last day of the
specified month wrap into later months. Thus, =DATE(2018, 2, 30) returns
March 2, 2018, because February does not have 30 days. Likewise, =DATE(2018,
2, 40) returns March 12, 2018.
FIGURE 12-4:
Splitting apart a
date with the
DAY, MONTH,
and YEAR
functions.
The DAY function is useful for this because you can use it to return just the day for
a lengthy list of dates. Then you can examine results by the day only.
1. Position the pointer in the cell where you want the results displayed.
Figure 12-5 shows how the DAY function can be used to analyze customer activity.
Column A contains a full year’s sequential dates (most of which are not visible in
the figure). In column B, the day part of each date has been isolated. Column C
shows the customer traffic for each day.
FIGURE 12-5:
Using the DAY
function to
analyze customer
activity.
This is all the information you need to analyze whether there is a difference in the
amount of customer traffic between the first half and second half of the month.
Cells E4 and E10 show the average daily customer traffic for the first half and
second half of the month, respectively. The value for the first half of the month
was obtained by adding all the customer values for day values in the range 1 to 15
and then dividing by the total number of days. The value for the second half of the
month was done the same way, using day values in the range 16 to 31.
The day parts of the dates, in column B, were key to these calculations: