Intro
Unlock the power of Google Sheets with our expert guide. Learn 5 simple ways to extract weekday names from dates, including using formulas, functions, and scripting. Discover how to automate tasks, streamline data analysis, and boost productivity with Google Sheets weekday functions, such as TEXT, WEEKNUM, and SCRIPT.
Managing dates and weekdays is an essential part of working with data in Google Sheets. Sometimes, you might need to extract the weekday name from a given date, which can be useful for scheduling, planning, or analyzing data based on days of the week. Google Sheets provides several functions and methods to achieve this. Here are five ways to get the weekday name from a date in Google Sheets.
Method 1: Using the TEXT Function
One of the straightforward methods to get the weekday name from a date is by using the TEXT function. The TEXT function in Google Sheets is used to convert a value to a text string in a specified format.
For example, if you have a date in cell A1 and you want to get the weekday name in cell B1, you can use the following formula:
=TEXT(A1, "dddd")
This formula converts the date in cell A1 to a text string representing the full weekday name. The "dddd" format specifier stands for the full weekday name.
Example Usage:
Date | Weekday Name |
---|---|
2023-02-20 | Monday |
2023-02-21 | Tuesday |
2023-02-22 | Wednesday |
Method 2: Using the WEEKDAY Function with SWITCH
Another approach involves using the WEEKDAY function in combination with the SWITCH function. The WEEKDAY function returns a number representing the day of the week (1 = Sunday, 2 = Monday,..., 7 = Saturday), and the SWITCH function allows you to convert this number into the corresponding weekday name.
Here’s how you can do it:
=SWITCH(WEEKDAY(A1), 1, "Sunday", 2, "Monday", 3, "Tuesday", 4, "Wednesday", 5, "Thursday", 6, "Friday", 7, "Saturday")
This formula might look more complex, but it gives you the weekday name based on the date in cell A1.
Example Usage:
Date | Weekday Name |
---|---|
2023-02-19 | Sunday |
2023-02-20 | Monday |
2023-02-21 | Tuesday |
Method 3: Using the CHOOSE Function with WEEKDAY
Similar to the SWITCH function, you can use the CHOOSE function to convert the weekday number returned by the WEEKDAY function into the weekday name.
The formula looks like this:
=CHOOSE(WEEKDAY(A1), "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
This method is concise and easy to understand.
Example Usage:
Date | Weekday Name |
---|---|
2023-02-18 | Saturday |
2023-02-19 | Sunday |
2023-02-20 | Monday |
Method 4: Using Array Formula with INDEX/MATCH
For a more advanced approach, you can use an array formula that utilizes the INDEX and MATCH functions. This method requires pressing Ctrl+Shift+Enter
after typing the formula to convert it into an array formula.
Here’s the formula:
=INDEX({"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, MATCH(WEEKDAY(A1), {1, 2, 3, 4, 5, 6, 7}, 0))
This formula creates an array of weekday names and then uses the WEEKDAY function to find the corresponding name for the date in cell A1.
Example Usage:
Date | Weekday Name |
---|---|
2023-02-17 | Friday |
2023-02-18 | Saturday |
2023-02-19 | Sunday |
Method 5: Using User-Defined Function (UDF) with Google Apps Script
For a more customized solution, you can create a user-defined function (UDF) using Google Apps Script. This involves writing a JavaScript function that you can then use as a formula in your Google Sheet.
To create a UDF, follow these steps:
- Open your Google Sheet.
- Click on
Tools
>Script editor
. This will open the Google Apps Script editor. - In the editor, delete any existing code and paste the following function:
function getWeekdayName(date) {
var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
return weekdays[new Date(date).getDay()];
}
- Save the script by clicking on the floppy disk icon or pressing
Ctrl+S
(orCmd+S
on a Mac). - Back in your Google Sheet, you can now use the UDF as a formula:
=getWeekdayName(A1)
This will return the weekday name for the date in cell A1.
Example Usage:
Date | Weekday Name |
---|---|
2023-02-20 | Monday |
2023-02-21 | Tuesday |
2023-02-22 | Wednesday |
Each of these methods has its own advantages and can be chosen based on your specific requirements or personal preference. Whether you're looking for simplicity, flexibility, or customization, Google Sheets provides the tools to efficiently extract weekday names from dates.
Weekday Name from Date in Google Sheets Image Gallery
We hope this comprehensive guide helps you understand how to extract weekday names from dates in Google Sheets efficiently. Feel free to explore each method further based on your specific needs.