Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less
Use Excel’s DATE function when you need to take three separate values and combine them to form a date.
The DATE function returns the sequential serial number that represents a particular date.
Syntax: DATE(year,month,day)
The DATE function syntax has the following arguments:
-
Year Required. The value of the year argument can include one to four digits. Excel interprets the year argument according to the date system your computer is using. By default, Microsoft Excel for Windows uses the 1900 date system, which means the first date is January 1, 1900.
Tip: Use four digits for the year argument to prevent unwanted results. For example, «07» could mean «1907» or «2007.» Four digit years prevent confusion.
-
If year is between 0 (zero) and 1899 (inclusive), Excel adds that value to 1900 to calculate the year. For example, DATE(108,1,2) returns January 2, 2008 (1900+108).
-
If year is between 1900 and 9999 (inclusive), Excel uses that value as the year. For example, DATE(2008,1,2) returns January 2, 2008.
-
If year is less than 0 or is 10000 or greater, Excel returns the #NUM! error value.
-
-
Month Required. A positive or negative integer representing the month of the year from 1 to 12 (January to December).
-
If month is greater than 12, month adds that number of months to the first month in the year specified. For example, DATE(2008,14,2) returns the serial number representing February 2, 2009.
-
If month is less than 1, month subtracts the magnitude of that number of months, plus 1, from the first month in the year specified. For example, DATE(2008,-3,2) returns the serial number representing September 2, 2007.
-
-
Day Required. A positive or negative integer representing the day of the month from 1 to 31.
-
If day is greater than the number of days in the month specified, day adds that number of days to the first day in the month. For example, DATE(2008,1,35) returns the serial number representing February 4, 2008.
-
If day is less than 1, day subtracts the magnitude that number of days, plus one, from the first day of the month specified. For example, DATE(2008,1,-15) returns the serial number representing December 16, 2007.
-
Note: Excel stores dates as sequential serial numbers so that they can be used in calculations. January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900. You will need to change the number format (Format Cells) in order to display a proper date.
Syntax: DATE(year,month,day)
For example: =DATE(C2,A2,B2) combines the year from cell C2, the month from cell A2, and the day from cell B2 and puts them into one cell as a date. The example below shows the final result in cell D2.
Need to insert dates without a formula? No problem. You can insert the current date and time in a cell, or you can insert a date that gets updated. You can also fill data automatically in worksheet cells.
-
Right-click the cell(s) you want to change. On a Mac, Ctrl-click the cells.
-
On the Home tab click Format > Format Cells or press Ctrl+1 (Command+1 on a Mac).
-
3. Choose the Locale (location) and Date format you want.
-
For more information on formatting dates, see Format a date the way you want.
You can use the DATE function to create a date that is based on another cell’s date. For example, you can use the YEAR, MONTH, and DAY functions to create an anniversary date that’s based on another cell. Let’s say an employee’s first day at work is 10/1/2016; the DATE function can be used to establish his fifth year anniversary date:
-
The DATE function creates a date.
=DATE(YEAR(C2)+5,MONTH(C2),DAY(C2))
-
The YEAR function looks at cell C2 and extracts «2012».
-
Then, «+5» adds 5 years, and establishes «2017» as the anniversary year in cell D2.
-
The MONTH function extracts the «3» from C2. This establishes «3» as the month in cell D2.
-
The DAY function extracts «14» from C2. This establishes «14» as the day in cell D2.
If you open a file that came from another program, Excel will try to recognize dates within the data. But sometimes the dates aren’t recognizable. This is may be because the numbers don’t resemble a typical date, or because the data is formatted as text. If this is the case, you can use the DATE function to convert the information into dates. For example, in the following illustration, cell C2 contains a date that is in the format: YYYYMMDD. It is also formatted as text. To convert it into a date, the DATE function was used in conjunction with the LEFT, MID, and RIGHT functions.
-
The DATE function creates a date.
=DATE(LEFT(C2,4),MID(C2,5,2),RIGHT(C2,2))
-
The LEFT function looks at cell C2 and takes the first 4 characters from the left. This establishes “2014” as the year of the converted date in cell D2.
-
The MID function looks at cell C2. It starts at the 5th character, and then takes 2 characters to the right. This establishes “03” as the month of the converted date in cell D2. Because the formatting of D2 set to Date, the “0” isn’t included in the final result.
-
The RIGHT function looks at cell C2 and takes the first 2 characters starting from the very right and moving left. This establishes “14” as the day of the date in D2.
To increase or decrease a date by a certain number of days, simply add or subtract the number of days to the value or cell reference containing the date.
In the example below, cell A5 contains the date that we want to increase and decrease by 7 days (the value in C5).
See Also
Add or subtract dates
Insert the current date and time in a cell
Fill data automatically in worksheet cells
YEAR function
MONTH function
DAY function
TODAY function
DATEVALUE function
Date and time functions (reference)
All Excel functions (by category)
All Excel functions (alphabetical)
Need more help?
When working with dates in Excel, sometimes you may want to know what day the date is (whether it’s a Monday or a Tuesday, or any other weekday).
This could especially be useful in project planning, where some days could be for a specific task (such as having a project meeting or sending the progress report), or where you need to know what days the working days are and what days are the weekends.
In this tutorial, I will show you a couple of ways you can use to convert dates into the day of the week and get its name in Excel.
So let’s get to it!
Get the Day Name Using Custom Number Formats
One of the best methods to convert a date into the day name is by changing the format of the cell that has the date.
The good thing about this method is that while you see the day name in the cell, in the back end, it still continues to be the date. This way, you can still use the dates in calculations.
Suppose you have a data set as shown below, where I have some dates in column A for which I want to know the name of the day.
Below are the steps to do this:
- Select the dates in column A
- Click the Home tab
- In the Number group, click on the dialog box launcher (the tilted arrow at the bottom right part of the group in the ribbon)
- In the Format Cells dialog box, click on the Custom category option
- In the Type field, enter dddd
- Click Ok
The above steps would convert the dates in the cells in column A and give you the name of the day for those dates.
And as I mentioned, doing, this would only change the way the dates are being displayed in the cells. In the back end, the cells still contain the dates that can be used in calculations.
When I use the custom code dddd, it tells Excel that I want to show only the day name from the date, and hide the month and the year value.
Below are the formats you can use when you working with dates in Excel:
- d – shows the day value from the date. If the day value is less than 10, only one digit is shown and if it’s 10 or more than 10, then two digits are shown.
- dd – shows the day value from the date in two digits. If the day value is less than 10, a leading zero is added to the number. For example, 5 would become 05
- ddd – this will show you the day name in the short format. If it’s Monday it would show you Mon, for Tuesday it will show Tue, and so on.
- dddd – when you use this custom format, it will show you the entire day name (such as Monday or Tuesday)
Note: For this method to work, you need to make sure that the dates are in a format that Excel understands as a date. For example, if you use Jan 21 2021, then it wouldn’t be converted into the day name as Excel doesn’t recognize this as a valid date format.
Get the Day Name Using TEXT Formula
You can also use the text formula in excel to convert a date into the name of the day.
However, unlike the above custom number format method, the result of the text formula would be a text string. This means that you would not be able to use the result of the text formula in calculations as a numeric or date value.
Let me show you how this method works.
Suppose I have a dates dataset as shown below and I want the name of the days in column B.
Below is the formula I can use to do this:
=TEXT(A2,"dddd")
The above formula will give you the full name of the day (such as Monday or Tuesday).
All the custom number formats that are covered in the above section can also be used in the text formula. Just make sure that the format is within double quotes (as the one shown in the formula above).
Now, you must be wondering why you would ever use the TEXT formula when the custom formatting method (covered before this method) gives you the same result and seems easier to use.
Let me show you in what situation using the TEXT formula to get day names can be useful.
Suppose I have the same data set as shown below, but now instead of getting the day name, I want to get an entire sentence where I have some text below or after the date name.
Let’s say I want to get the result as ‘Due Date – Monday’ (i.e., I want to add some text before the day name)
I can use the below formula to do this:
="Due Date: "&TEXT(A2,"dddd")
Or, another example could be where you want to show whether the day is Weekday or Weekend followed by the day name. This can be done using the below formula:
=IF(WEEKDAY(A2,2)>5,"Weekend: ","Weekday: ")&TEXT(A2,"dddd")
I’m sure you get the idea.
The benefit of using the TEXT formula is that you can combine the result of that formula with other formulas (such as IF function or AND/OR function).
Get the Day Name Using CHOOSE and WORKDAY formula
And lastly, let me show you how to get the denim using a combination of CHOOSE and WORKDAY formulas.
Below I have the data set where I have the dates in column A for which I want to get the day name.
Here is the formula that will do this:
=CHOOSE(WEEKDAY(A2,2),"Mon","Tue","Wed","Thu","Fri","Sat","Sun")
In the above formula, I have used the WEEKDAY formula to get the weekday number of any given date.
Since I’ve specified the second argument of the weekday formula as 2, it would give me 1 for Monday, 2 for Tuesday, and so on.
This value is then used within the CHOOSE formula to get the day name (which is something that I have already specified in the formula).
This is definitely bigger and more complex than the TEXT formula we used in the previous section.
But there is one scenario where using this formula can be useful – when you want to get something specific to that day instead of getting the day name.
For example, below is the same formula where I have changed the day name with specific activities that need to be done on those days.
=CHOOSE(WEEKDAY(A2,2),"Townhall","Proj Update Call","Buffer day","Support","Weekly Checkin","Weekend","Weekend")
In the above formula, instead of using the day names, I have used the name of the activities that need to be done on those days.
So these are three easy and simple ways you can use to convert a date value into the day name in Excel.
I hope you found this tutorial helpful!
Other Excel tutorials you may also like:
- How to Get the First Day of the Month in Excel (Easy Formulas)
- How to Add or Subtract Days to a Date in Excel
- How to Calculate the Number of Days Between Two Dates in Excel
- How to Group Dates in Pivot Tables in Excel (by Years, Months, Weeks)
- How to Calculate Age in Excel using Formulas + FREE Calculator Template
- Check IF a Date is Between Two Given Dates in Excel
- How to Autofill Only Weekday Dates in Excel (Formula)
Bottom line: With Valentine’s Day rapidly approaching I thought it would be good to explain how you can get a date with your Excel skills. Just kidding! 🙂 This post and video explain how the date calendar system works in Excel.
Skill level: Beginner
Dates in Excel can be just as complicated as your date for Valentine’s Day. We are going to stick with dates in Excel for this article because I’m not qualified to give any other type of dating advice. 🙂
Video Tutorial on How Dates Work in Excel
The following is a video from The Ultimate Lookup Formulas Course on how the date system works in Excel.
Watch the Video on YouTube
There are over 100 short videos just like the one above included in the Ultimate Lookup Formulas Course.
This course has been designed to help you master Excel’s most important functions and formulas in an easy step-by-step manner.
The Ultimate Lookup Formulas course is now part of our comprehensive Elevate Excel Training Program.
Click Here to Learn More About Elevate Excel
What is a Date in Excel?
I should first make it clear that I am referring to a date that is stored in a cell.
The dates in Excel are actually stored as numbers, and then formatted to display the date. The default date format for US dates is “m/d/yyyy” (1/27/2016).
The dates are referred to as serial numbers in Excel. You will see this in some of the date functions like DAY(), MONTH(), YEAR(), etc.
So then, what is a serial number? Well let’s start from the beginning.
The date calendar in Excel starts on January 1st, 1900. As far as Excel is concerned this day starts the beginning of time.
Each Day is a Whole Number
Each day is represented by one whole number in Excel. Type a 1 in any cell and then format it as a date. You will get 1/1/1900. The first day of the calendar system.
Type a 2 in a cell and format it as a date. You will get 1/2/1900, or January 2nd. This means that one whole day is represented by one whole number is Excel.
You can also take a cell that contains a date and format it as a number.
For example, this post was published on 1/27/2016. Put that number in a cell (the keyboard shortcut to enter today’s date is Ctrl+;), and then format it as a number or General.
You will see the number 42,396. This is the number of days that have elapsed since 1/1/1900.
Date Based Calculations
It is important to know that dates are stored as the number of days that have elapsed since the beginning of Excel’s calendar system (1/1/1900).
When you calculate the difference between two dates by subtraction, the result will be the number of days between the two dates.
1/27/2016 – 1/1/2016 = 26 days
6/30/2016 – 1/1/2016 = 181 days
There are a lot of Date functions in Excel that can help with these calculations. Last week we learned about the DAY function for month-to-date calculations with pivot tables.
We won’t go into all the date functions here, but understanding that the serial number represents one day will give you a good foundation for working with dates.
What About Dates with Times?
Do you ever work with dates that contain time values?
These dates are still stored as serial numbers in Excel. When you convert the date with a time to the number format, you will see a decimal number.
This decimal is a fraction of the day.
One hour in Excel is represented by the number: 1/24 = 0.04167
One minute in Excel is represented by the number: 1/(24*60) = 1/1440 = 0.000694
So 8:30 AM can be calculated as: (8 * (1/24)) + (30 * (1/1440)) = .354167
An easier way to calculate this is by typing 8:30 AM in a cell, then changing the format to Number.
So if you are running a half hour late and want to let your boss know, text him/her and say you will be there at 0.354167. 🙂
Checkout my article on 3 ways to group times in Excel for more date time based calculations.
Don’t Talk About Excel Dates with Your Date
Unless your Valentine shares a similar passion for Excel, I strongly recommend NOT sharing this information on your date.
I remember the first time I met my wife, and told her I worked in finance. The first word out of her mouth was, “BORING!”. Awe… it was love at first sight… LOL 🙂
But you should now be able to use Excel to determine how many days it has been since you last spoke to your date. That’s the only dating advice I can give.
Please leave a comment below with any questions on Excel dates. Thanks!
When working with date-specific information, there might be instances where you need to find the day of the week corresponding to a date.
For example, instead of the date, you may want to know whether it’s a Monday or a Tuesday or any other day.
This could be useful when working with to-do lists, daily/weekly summary reports, etc.
In this tutorial, we will see three different ways of converting dates to the corresponding day of the week in Excel.
For all the three methods in this tutorial, we will be using the following sample dataset.
We will convert all the dates in the above sample dataset into corresponding days of the week.
Method 1: Converting Date to Day of Week in Excel using the TEXT Function
The TEXT function is a great function to convert dates to different text formats.
It takes a date serial number or date and lets you extract parts of the date to fit your required format.
Here’s the syntax for the TEXT function:
= TEXT (date, date_format_code)
In this function,
- date is the date, date serial number, or reference to the cell that you want to convert.
- date_format_code is the format code based on how you want the converted date to look.
The TEXT function applies the date_format_code that you specified on the provided date and returns a text string with that format.
For example, if you have the date “2/10/2018” in cell A2, then =TEXT(A2,”dddd”) will return “Saturday”.
Here, “dddd” is the date_format code to display the day of the week corresponding to date in full words.
Here are some basic building blocks for the format codes that you can use:
Format Codes for Day of the Week or Month:
You can use the following basic format codes to represent day values:
- d – one or two-digit representation of the day (eg: 3 or 30)
- dd – two-digit representation of the day (eg: 03 or 30)
- ddd – the day of the week in abbreviated form (eg: Sun, Mon)
- dddd – full name of the day of the week (eg: Sunday, Monday)
So,
- if you apply =TEXT(A2, “d”) to the sample dataset, it will return “10”.
- if you apply =TEXT(A2, “dd”), then it will return “10”.
- if you apply =TEXT(A2, “ddd”) to the sample dataset, it will return “Sat”.
- if you apply =TEXT(A2, “dddd”), then it will return “Saturday”.
Let us see how we can apply the TEXT function to our sample dataset to convert all the dates to days of the week.
We will first see how to convert the dates in column A to the format shown in column B in the image below:
Below are the steps to convert the date to a weekday name using the TEXT function:
- Click on a blank cell where you want the day of the week to be displayed (B2)
- Type the formula: =TEXT(A2,”ddd”) if you want the shortened version of the day or =TEXT(A2,”dddd”) if you want the full version of the day.
- Press the Return key.
- This should display the day of the week in our required format. Copy this to the rest of the cells in the column by dragging down the fill handle or double-clicking on it.
- Copy this column’s formula results by pressing CTRL+C or Cmd+C (if you’re on a Mac).
- Right-click on the column, and from the popup menu that appears, press Paste Values from the Paste Options.
- This will store the formula results as permanent values in the same column. Now you can go ahead and remove column A if you want to.
You should see all the dates converted to the short form of their corresponding days of the week:
The result you get in column B will differ according to the format code you used in step 2. Here are some format codes along with the type of result you will get when applied to cell A2:
Function | Result |
=TEXT(A2, “ddd”) | Sat |
=TEXT(A2, “dddd”) | Saturday |
Note: Using this formula, your converted date is in text format, so you will see the results aligned to the left side of the cells.
Also read: How to Convert Date to Serial Number in Excel?
Method 2: Converting Date to Day of Week in Excel using the Format Cells Feature
The Format Cells feature provides a great way to directly convert your dates to days of the week while replacing the existing dates. As such you don’t need to have a separate column to type the formula.
You can use the Format Cells dialog box to convert your dates to days of the week as follows:
- Select all the cells containing the dates that you want to convert (A2:A8).
- Right-click on your selection and select Format Cells from the popup menu that appears. Alternatively, you can select the dialog box launcher in the Number group under the Home tab.
- This will open the Format Cells dialog box. Click on the Number tab
- Under Category on the left side of the box, select the Custom option.
- This will display a number of formatting options on the right side, under Type. You can type in your format code in the Type field. You can type in “ddd” if you want the short form or “dddd” if you want the full form of the day.
- Click OK to close the Format Cells dialog box.
All your selected cells should now appear as weekday names.
Note: By using Format Cells, you have just changed the format in which the dates are displayed in the cells. The actual dates are underlying the cells and can be seen in the formula bar when a cell is selected.
Also read: How to Convert Text to Date in Excel?
Method 3: Converting Date to Day of Week in Excel using a Formula
If you’d rather use your own representation for the days of the week, you can use a formula based on both the WEEKDAY and CHOOSE functions.
First, let us understand these two functions individually.
The WEEKDAY Function
The WEEKDAY function converts a date to a number between 1 and 7, one for each day of the week. It chooses the sequencing of these numbers based on the day we want the week to begin from.
This is helpful because in some countries, the week starts from Sunday, while in others, especially Middle Eastern countries, the week starts from Saturday.
The syntax for the WEEKDAY function is:
WEEKDAY(date, [type])
Here,
- date is the input date for the function. It can be a date, a date serial number, or a reference to a cell that holds a date value.
- type is an optional parameter. It tells the function where to begin the week from. So, if we put a 1, it means the week should start from Sunday and end on Saturday. If we put a 2, it means the week should start from Monday and end on Sunday, and so on. By default, the value for the type parameter is set to 1.
In our example, WEEKDAY(A2, 1) will return 7, corresponding to a Saturday.
The CHOOSE Function
The CHOOSE function lets you specify a particular outcome depending on a value. For example, you can choose to display the word “red” if a value is 1, “blue” if it is 2, “green” if it is 3, and so on.
In this way it’s a great alternative to using a bunch of nested IF functions.
The syntax for the CHOOSE function is:
=CHOOSE (index, value1, [value2], ...)
Here,
- index is the input value. It can be any number between 1 and 254.
- value1 is the first value from the list of possible outputs
- value2 is the second value from the list of possible outputs,
etc.
The function returns value1 if index is 1, value2 if index is 2, etc.
So the function: =CHOOSE(3, “sun”,”mon”,”tue”,”wed”,”thu”,”fri”, ”sat”) will return “tue”, because it’s the third value in the list.
Putting the Formula Together
Let us put the two functions CHOOSE and WEEKDAY together to convert date to day of the week. Here are the steps to follow:
- Click on a blank cell where you want the day of the week to be displayed (B2)
- Type the formula: =CHOOSE(WEEKDAY(A2),”Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”)
- Press the Return key.
- This should display the day of the week in short form, corresponding to the date in A2. Copy this to the rest of the cells in the column by dragging down the fill handle or double-clicking on it.
- Copy this column’s formula results by pressing CTRL+C or Cmd+C (if you’re on a Mac).
- Right-click on the column and form the popup menu that appears, press Paste Values from the Paste Options.
- This will store the formula results as permanent values in the same column. Now you can go ahead and remove column A if you want to.
Here’s what you should get as the result:
How did this Formula Work?
To understand how this formula worked, we need to break it down:
- First, we used the WEEKDAY function to find the number corresponding to the day of the week, assuming our week starts from Sunday. This will return a number between 1 and 7.
- We used the output of the WEEKDAY function to find the string from the list of days [“sun”,”mon”,”tue”,”wed”,”thu”,”fri”, “sat”] corresponding to that number. So if the output for WEEKDAY(A2) was 7, then the corresponding output for the CHOOSE function will be the seventh item in the list, which is “sat”.
Thus we get the day corresponding to the date in A2 (in our example) to be “sat”.
Note: The above formula will give your converted date in text format, so you will see the results aligned to the left side of the cells.
You could also have any other format for the days in the list, for example, if you wanted to display just the first two letters for the days, you could have written the formula in step 2 as:
=CHOOSE(WEEKDAY(A2),"Su","Mo","Tu","We","Th","Fr","Sa")
So you could get an output as:
If you wanted to make a to-do list, you could even have an activity for each day of the week. For example, you could use the formula:
=CHOOSE(WEEKDAY(A2),"cycling","rollerblading","swimming","skiing","art","crafts","free time")
So you could get an output as:
In this tutorial, we saw three ways to convert a date to the day of the week.
The first method involves a function (TEXT), the second method involves a commonly used Excel dialog box (Format Cells) and the third method involves an Excel formula (with WEEKDAY and CHOOSE functions).
We hope you found this tutorial helpful and easy to apply to your data.
Other Excel tutorials you may find useful:
- How to Convert Serial Numbers to Date in Excel
- How to Convert Date to Month and Year in Excel
- How to Get Total Days in Month in Excel?
- How to Add Days to a Date in Excel
- How to Sort by Date in Excel (Single Column & Multiple Columns)
- Why are Dates Shown as Hashtags in Excel?
- How to Convert Month Number to Month Name in Excel
- How to Convert Days to Years in Excel (Simple Formulas)
- How to Get the First Day Of The Month In Excel?
In this example, the goal is to get the day name (i.e. Monday, Tuesday, Wednesday, etc.) from a given date. There are several ways to go about this in Excel, depending on your needs. This article explains three approaches:
- Display date with a custom number format
- Convert date to day name with TEXT function
- Convert date to day name with CHOOSE function
For all examples, keep in mind that Excel dates are large serial numbers, displayed as dates with number formatting.
Day name with custom number format
To display a date using only the day name, you don’t need a formula; you can just use a custom number format. Select the date, and use the shortcut Control + 1 to open Format cells. Then select Number > Custom, and enter one of these custom formats:
"ddd" // i.e."Wed"
"dddd" // i.e."Wednesday"
Excel will display only the day name, but it will leave the date intact. If you want to display both the date and the day name in different columns, one option is to use a formula to pick up a date from another cell, and change the number format to show only the day name. For example, in the worksheet shown, cell F5 contains the date January 1, 2000. The formula in G5, copied down, is:
=F5 // get date from F5
Cells G5 and G6 have the number format «dddd» applied, and cells in G7:G9 have the number format «ddd» applied.
Day name with TEXT function
To convert a date to a text value like «Saturday», you can use the TEXT function. The TEXT function is a general function that can be used to convert numbers of all kinds into text values with formatting, including date formats. For example, with the date January 1, 2000 in cell A1, you can use TEXT like this:
=TEXT(A1,"d-mmm-yyyy") // returns "1-Jan-2000"
=TEXT(A1,"mmmm d, yyyy") // returns "January 1, 2000"
=TEXT(A1,"mmmm") // returns "January"
In the worksheet shown, the goal is to display the day name only, so we use a custom number format like «ddd» or «dddd»:
=TEXT(B5,"dddd") // returns "Saturday"
=TEXT(B5,"ddd") // returns "Sat"
Note: The TEXT function converts a date to a text value using the supplied number format. The date is lost in the conversion and only the text for the day name remains.
Day name with CHOOSE function
For maximum flexibility, you can create your own day names with the CHOOSE function. CHOOSE is a general-purpose function for returning a value based on a numeric index. For example, you can use CHOOSE to return one of three colors with a number like this:
=CHOOSE(1,"red","blue","green") // returns "red"
=CHOOSE(2,"red","blue","green") // returns "blue"
=CHOOSE(3,"red","blue","green") // returns "green"
In this example, the goal is to return a day name from a date, so we need to configure CHOOSE to select one of seven-day names. For example, the formula below would return «Wed» based on a numeric index of 4:
=CHOOSE(4,"Sun","Mon","Tue","Wed","Thu","Fri","Sat") // "Wed"
The challenge in this case is to get the right index for a date and for that we need the WEEKDAY function. For any given date, WEEKDAY returns a number between 1-7, which corresponds to the day of the week. By default, WEEKDAY returns 1 for Sunday, 2 for Monday, 3 for Tuesday, etc. In the worksheet shown, the formula in C12 is:
=CHOOSE(WEEKDAY(B12),"Sun","Mon","Tue","Wed","Thu","Fri","Sat")
WEEKDAY returns a number between 1-7, and CHOOSE will use this number to select the corresponding value in the list. Since the date in B12 is January 1, 2000, WEEKDAY returns 7, and CHOOSE returns «Sat».
CHOOSE is more work to set up, but it is also more flexible, since it allows you to convert a date to a day name using any values you want. For example, you can use custom abbreviations or even abbreviations in a different language. In cell C15, CHOOSE is set up to use one letter abbreviations that correspond to Spanish day names:
=CHOOSE(WEEKDAY(B15),"D","L","M","X","J","V","S")
Empty cells
If you use the formulas above on an empty cell, you’ll get «Saturday» as the result. This happens because an empty cell is evaluated as zero, and zero in the Excel date system is the date «0-Jan-1900», which is a Saturday. To work around this issue, you can use the IF function to return an empty string («») for empty cells. For example, if cell A1 may or may not contain a date, you can use IF like this:
=IF(A1<>"",TEXT(A1,"ddd"),"") // check for empty cells
The literal translation of this formula is: If A1 is not empty, return the TEXT formula, otherwise return an empty string («»).