Vous êtes sur la page 1sur 8

Converting a Date in Excel to Week, Bi-Week, Month, and More TimWilson at Web Analytics Demystified

http://tim.webanalyticsdemystified.com/?p=2030[5/26/2014 10:46:38 AM]


All posts from Tim Wilson
Web Analytics Demystified
SERVICES STAFFING SUPPORT TRAINING CONTACT
Registration is now open for ACCELERATE 2014 in Atlanta, Georgia on September 18th. Reserve your spot today at Eventbrite
tickets are only $99 USD!
Converting a Date in Excel to Week, Bi-Week, Month, and More
Published by Tim Wilson on J anuary 15, 2013
I often find myself getting data out of one system or another (or multiple systems, and then combining them) as daily data a series of
metrics by day for a sequence of days. Sometimes, I work with that data at a daily level, but, often, I want to roll the data up by week, by
month, or by some other time period.
For instance, if I want to look at the data weekly, Ill use either the last day of the week or the first day of the week and then use a formula
in a new column to convert each actual day to the week in which it falls:
Excel Date Conversion
In the example above, 1/15/2013 is a Tuesday that falls in a week that ends on Saturday, 1/19/2013. The same holds true for Wednesday
(1/16), Thursday (1/17), Friday (1/18), and Saturday (1/19). As soon as get to 1/20/2013 (Sunday), Im in a new week a week that ends
on 1/26/2013. Make sense?
By adding this column, I can create a pivot table that can easily generate weekly data for whatever metrics are in the spreadsheet.
This approach works for a number of different ways you might need to roll up daily data, so I thought a post that walks through some of
the more common ones and the formula to carry out each conversion was in order. Ive put all of the examples in this post in
a downloadable spreadsheet that you can check out and play around with.
Converting a Date in Excel to Week, Bi-Week, Month, and More TimWilson at Web Analytics Demystified
http://tim.webanalyticsdemystified.com/?p=2030[5/26/2014 10:46:38 AM]
Day of Week
The WEEKDAY() function returns a number 1, 2, 3, 4, 5, 6, or 7. But, what if you actually want the day of the week in plain English?
Excel Dates: Weekdays
You can use the CHOOSE() function and hard code values. Or, you can make a separate table that maps a number to each weekday and
use VLOOKUP to populate the values. Im not going to discuss either of those approachesbecause my preferred approach is to use the
TEXT() function.
For the fully written out weekday ($A3 is the cell with 1/15/2013 in it you would just drag this formula down, or, if youre using an
Excel Table, it would autofill):
=TEXT($A3,dddd)
For the 3-letter weekday:
=TEXT($A3,ddd)
Easy-peasy, no?
Note: If you simply want the date to be displayed as the weekday, you dont need a formula at all you can simply change the cell
formatting to a custom format of dddd (for the full weekday) or ddd (for the 3-letter weekday). If you do that, the display of the data
will be as a weekday, but the underlying value will still be the actual date. This formula actually makes the value the weekday. Depending
on what your needs are, one approach or the other will make more sense.
Convert to Week Of
The example I started this post with is converting each day to be the day that ends the week or the day that starts the week. To do this, you
can use the WEEKDAY() function. The easiest way to understand how this works out is to write out (or put in Excel) a series of dates and
then write the numbers 1 through 7 as you go down the dates. The farther you go into a week, the bigger the WEEKDAY() value is. So, if
you subtract the WEEKDAY() value from the actual date, you will get the same value 7 days in a row, at which point the value will
jump seven days. Make sense (its confusinguntil its not)?
So, to convert a date to be the Saturday of the week the date falls in, use this formula (the +7 just keeps the converted value from being
the Saturday of the previous week):
=$A3-WEEKDAY($A3)+7
Its the same idea if you wanted to use the first day of the week, with the week defined as starting on Sunday:
=$A3-WEEKDAY($A3)+1
Obviously, you can use this basic formula for whatever week criteria you want. You just have to either think about it really hardor
experiment until its doing what you want.
Convert to Bi-Weekly Date
Sometimes, a company operates on a bi-weekly cycle in some ways. For instance, a lot of companies pay their employees every two
Converting a Date in Excel to Week, Bi-Week, Month, and More TimWilson at Web Analytics Demystified
http://tim.webanalyticsdemystified.com/?p=2030[5/26/2014 10:46:38 AM]
weeks. WEEKDAY() doesnt work for this, because it doesnt tell you which of the two weeks a day falls into.
In this case, I use MOD(). This function is, basically, a remainder function, and its main use is to calculate the remainder when one
number is divided by another (for instance, =MOD(14,4) returns 2 because, when you divide 14 by 4, you get a remainder of 2).
Well, Excel dates are, under the hood, just numbers. You dont really need to know exactly what number a date is (although you can
change the cell formatting to Number when a date is displayed and you will see the number). But, if you think about it, if you divide a
date by 14, its going to have a remainder between 1 and 13. Lets say the remainder is 2. So, what will the remainder be if you divide
the next day by 14? It will be 3. And so on until you get to 13, at which point the next day, if divided by 14, will have a remainder of 0.
Hmmm. This seems like weve recreated the WEEKDAY() function used abovebut with a 14-day long period instead of 7-day one,
right? Exactly!
So, if we wanted to convert a date to be the Saturday at the end of the bi-week period, it would be one of these two formulas (depending on
which Saturday is the cutoff and which is the mid-period point):
=$A3-MOD($A3-1,14)+13
or
=$A3-MOD($A3-8,14)+13
If you wanted to use the start of the period, with the week starting on Sunday, then it would be one of these two formulas:
=$A3-MOD($A3-1,14)
or
=$A3-MOD($A3-8,14)
Again, it takes some experimentation if you want to adjust to other dates, but the 14 will not change as long as youre working on bi-
weekly periods.
Convert to Bi-Monthly Date
Sometimes (again, company pay periods are a good example), rather than using a bi-weekly calendar, you want to use a bi-monthly
calendar every date from the 1st through the 14th should be converted to the first day of the month, and every day from the 15th
through the end of the month should be coded as the 15th. To do this, we use the DATE() function with an IF() statement for the day
value:
=DATE(YEAR($A3),MONTH($A3),IF(DAY($A3)<15,1,15))
We know the year is the YEAR() of the date being converted, and we know the month is the MONTH() of the date being converted. But,
we need to look at the day of the month and check if it is less than 15. If it is, then we return a day value of 1, and, otherwise, we return
a day value of 15.
Convert to Monthly Date
Monthly is almost as common, if not moreso, than weekly. To convert to the first day of the month is a straightforward use of the DATE()
function. We pull the year using the YEAR() function on the date were converting, the month using the MONTH() function on the date
were converting, and then simply hard code the day as 1:
=DATE(YEAR($A3),MONTH($A3),1)
But, what if we want to use the last day of the month? We cant hard code the day value because that day could be 28, 29 (leap year), 30,
or 31. Curse you, Gregorian calendar!!!
Well, actually, this isnt all that complicated, either. Why? Because the last day of the month is always the day before the first day of the
next month. Huh? Thats right. Thats how we get the last day of the month: we use the DATE() function to figure out the first day of
the next month (by adding 1 to the MONTH() value) and then subtract 1:
=DATE(YEAR($A3),MONTH($A3)+1,1)-1
How do you like them apples?! [idiom ref.]
As an interesting aside, it would be understandable if this formula broke for the month of December. In that case, youre actually telling
Excel to calculate a date where the month is 13. Luckily, Excel figures out what you mean and winds up returning J anuary 1 of the
Converting a Date in Excel to Week, Bi-Week, Month, and More TimWilson at Web Analytics Demystified
http://tim.webanalyticsdemystified.com/?p=2030[5/26/2014 10:46:38 AM]
following year (from which the formula then subtracts one to return December 31st).
But, What About
Ive just scratched the surface with possible date conversions in this post. Hopefully, the different approaches I described will trigger an
idea or two for your specific situation. But, if youve got one that is stumping you, leave a comment here and Ill take a crack at it!
And, all of the examples here are included in this downloadable spreadsheet. You can change the start date in cell A3 and all of the
subsequent dates will automatically update. Happy date converting!
www.simplesharebuttons.comShare this blog post ...
Categorized under Excel
0 0 0 2
Converting a Date in Excel to Week, Bi-Week, Month, and More TimWilson at Web Analytics Demystified
http://tim.webanalyticsdemystified.com/?p=2030[5/26/2014 10:46:38 AM]
... more from Eric T. Peterson

Recent Blog Posts
The Recent Forrester Wave on Web Analytics ... is Wrong
Eric T. Peterson, Senior Partner
Having worked as an industry analyst back in the day I still find
myself interested in what the analyst community has to say about web
analytics, especially when it comes to vendor evaluation. The
evaluations are interesting because of the sheer amount of work that
goes into them in an attempt to distill entire companies down into
simple infographics, tables, and single paragraph summaries.
Continue reading this article ...
Funnel Visualizations That Make Sense
Tim Wilson, Partner
Funnels, as a concept, make some sense (although someone once
made a good argument that they make no sense, since, when the
concept is applied by marketers, the funnel is really more a "very,
Contact Us
You can contact Web Analytics
Demystified day or night via email or
by reaching out to one of our Partners
directly.
Contact Information
Web Analytics Demystified, Inc.
P.O. Box 13303
Portland, OR 97213
(503) 282-2601
Useful Links
Demystified Consulting
Converting a Date in Excel to Week, Bi-Week, Month, and More TimWilson at Web Analytics Demystified
http://tim.webanalyticsdemystified.com/?p=2030[5/26/2014 10:46:38 AM]
... more from Tim Wilson
... more from Adam Greco
... more from Eric T. Peterson
... more from Adam Greco
... more from Tim Wilson
... more from Adam Greco
very leaky funnel," which would be a worthless funnel real-world
funnels get all of a liquid from a wide opening through a smaller
spout; but, lets not quibble).
Continue reading this article ...
Reenergizing Your Web Analytics Program & Implementation
Adam Greco, Senior Partner
Those of you who have read my blog posts (and book) over the years,
know that I have lots of opinions when it comes to web analytics, web
analytics implementations and especially those using Adobe
Analytics. Whenever possible, I try to impart lessons I have learned
during my web analytics career so you can improve things at your
organization.
Continue reading this article ...
Registration for ACCELERATE 2014 is now open
Eric T. Peterson, Senior Partner
I am excited to announce that registration for ACCELERATE 2014 on
September 18th in Atlanta, Georgia is now open. You can learn more
about the event and our unique "Ten Tips in Twenty Minutes" format
on our ACCELERATE mini-site, and we plan to have registration
open for our Advanced Analytics Education pre-ACCELERATE
training sessions in the coming weeks.
Continue reading this article ...
Current Order Value
Adam Greco, Senior Partner
I recently had a client pose an interesting question related to their
shopping cart. They wanted to know the distribution of money its
visitors were bringing with them to each step of the shopping cart
funnel.
Continue reading this article ...
A Guide to Segment Sharing in Adobe Analytics
Tim Wilson, Partner
Over the past year, I've run into situations multiple times where I
wanted an Adobe Analytics segment to be available in multiple Adobe
Analytics platforms. It turns outthat's not as easy as it sounds. I
actually went multiple rounds with Client Care once trying to get it
figured out. And, Ive found "the answer" on more than one occasion,
only to later realize that that answer was a bit misguided.
Continue reading this article ...
Currencies & Exchange Rates
Adam Greco, Senior Partner
If your web analytics work covers websites or apps that span different
countries, there are some important aspects of Adobe SiteCatalyst
(Analytics) that you must know. In this post, I will share some of the
things I have learned over the years related to currencies and exchange
rates in SiteCatalyst.
Continue reading this article ...
Strategic Consulting
Adobe Analytics Audit
Analytics Implementation Support
Ongoing Analytics Support
"Team Demystified" Staffing
Dedicated Contractors
Direct Hire Services
J oin "Team Demystified"
About Demystified
Partners and Senior Partners
Our Work in Analytics
Our Commitment
Our LinkedIn Page
Community Support
Advanced Analytics Education
Analysis Exchange
Web Analytics Wednesday
The ACCELERATE Conference
Thought Leadership
Online Presentations
White Papers
Book Downloads
Partner Blogs
Eric T. Peterson
J ohn Lovett
Adam Greco
Brian Hawkins
Kevin Willeitner
Michele Kiss
J osh West
Tim Wilson
Search Demystified
Converting a Date in Excel to Week, Bi-Week, Month, and More TimWilson at Web Analytics Demystified
http://tim.webanalyticsdemystified.com/?p=2030[5/26/2014 10:46:38 AM]
... more from Adam Greco
... more from Eric T. Peterson
... more from Tim Wilson
... more from Adam Greco
... more from Tim Wilson
... more from Michele Kiss
Linking Authenticated Visitors Across Devices
Adam Greco, Senior Partner
In the last few years, people have become accustomed to using
multiple digital devices simultaneously. While watching the recent
winter Olympics, consumers might be on the Olympics website, while
also using native mobile or tablet apps. As a result, some of my clients
have asked me whether it is possible to link visits and paths across
these devices so they can see cross-device paths and other behaviors.
Continue reading this article ...
The 80/20 Rule for Analytics Teams
Eric T. Peterson, Senior Partner
I had the pleasure last week of visiting with one of Web Analytics
Demystifieds longest-standing and, at least from a digital analytical
perspective, most successful clients. The team has grown
tremendously over the years in terms of size and, more importantly,
stature within the broader multi-channel business and has become one
of the most productive and mature digital analytics groups that I personally am aware
of across the industry.
Continue reading this article ...
Ten Things You Should ALWAYS Do (or Not Do) in Excel
Tim Wilson, Partner
Last week I was surprised by the Twitter conversation a fairly
innocuous vent-via-Twitter tweet started, with several people noting
that they had no idea you could simple turn off the gridlines.
Continue reading this article ...
Omni Man (and Team Demystified) Needs You!
Adam Greco, Senior Partner
As someone in the web analytics field, you probably hear how lucky
you are due to the fact that there are always web analytics jobs
available. When the rest of the country is looking for work and you
get daily calls from recruiters, it isnt a bad position to be in! At Web
Analytics Demystified, we have more than doubled in the past year
and still cannot keep up with the demand, so I am reaching out to you ...
Continue reading this article ...
A Useful Framework for Social Media "Engagements"
Tim Wilson, Partner
Whether you have a single toe dipped in the waters of social media
analytics or are fully submerged and drowning, youve almost
certainly grappled with "engagement." This post isnt going to answer
the question "Is engagement ROI?" ...
Continue reading this article ...
Its not about "Big Data", its about the "RIGHT data"
Michele Kiss, Partner
Unless youve been living under a rock, you have heard (and perhaps
grown tired) of the buzzword "big data." But in attempts to chase the
"next shiny thing", companies may focus too much on "big data"
rather than the "right data."
Continue reading this article ...
Converting a Date in Excel to Week, Bi-Week, Month, and More TimWilson at Web Analytics Demystified
http://tim.webanalyticsdemystified.com/?p=2030[5/26/2014 10:46:38 AM]
Eric T.
Peterson
J ohn
Lovett
Adam
Greco
Brian
Hawkins
Kevin
Willeitner
Michele
Kiss
J osh
West
Tim
Wilson
Copyright 2014 Web Analytics Demystified, Inc., Portland, Oregon, USA feedback@webanalyticsdemystified.com

Vous aimerez peut-être aussi