Return Weekday Of Date

  • <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><meta http-equiv="Content-Language" content="en-us"><title>Return Day Of Week Of Excel Date</title><meta name="description" content="Return Day Of Week Of Excel Date"><meta name="keywords" content="Return Day Of Week Of Excel Date"><link rel="STYLESHEET" href="" type="text/css"><script type="text/javascript" src=""></script>
    </head><body><a name="top"></a><h1>Return Day Of Week Of Date</h1><h2>Return Day Of Week Of Date</h2><p class="j">When finding the weekday associated with any date, most of us would rather see it returned as a name of the day, rather than as a number (the default).</p><p class="j">Here we show how to extract the weekday of any date by using the WEEKDAY function. By default, the day is given as a whole number, ranging from 1 (Sunday) to 7 (Saturday). However, this is often meaningless, and we usually would rather see the weekday returned as a name, such as Monday/Mon, Tuesday/Tue, and so on.</p><h3>Get the Weekday as a Number</h3><p class="j">Before getting to the name of the day, we'll need to begin by extracting the number of the weekday. Here's the syntax for the WEEKDAY formula:</p><p>WEEKDAY(serial_number,return_type)</p><p class="j">Lets say we want to return the weekday number of 31-Jul-2007 The serial_num is any valid date in this case 31-Jul-2007 and the return_type is a number that refers to the type of return value. Depending on what result you are looking for will determine the return_type that you will use:</p><div align="center"><table border="0" width="45%"><tr><th>return_type</th><th>Day of Week</th></tr><tr><td><br>1 or omitted</td><td>Numbers 1 (Sunday) through to 7 (Saturday)</td></tr><tr><td>2</td><td>Numbers 1 (Monday) through 7 (Sunday)</td></tr><tr><td>3</td><td>Numbers 0 (Monday) through 6 (Sunday)</td></tr></table></div><p class="j">We will use the default function by omitting the return-type. Click in cell A1 and type in a valid Excel date, such as 31-Jul-2007 (which is a Tuesday). Then, click in cell B1 and enter the following formula:<br>=WEEKDAY(A1)</p><p class="j">This formula will return the number 3, which equates to Tuesday, which is the day of the week that 31 July 2007 is.</p><p class="j">An alternative would be to hardcode the date like this:<br>=WEEKDAY(&quot;31 Jul 2007”)</p><h3>Return the Weekday as Weekday Name</h3><p class="j">Remember, the WEEKDAY formula shown in the previous section only returns the weekday as a number. There are at least two ways we can use formulas to force Excel to show the actual name of the weekday.</p><p class="j"><br>The first method is perhaps the simplest, and all you need to do is apply a custom number format of DDD or DDDD. Again using 31-Jul-2007 as an example, select the date cell, right-click, go to Format Cells, and then choose Number tab&gt;Custom. Enter in the custom format DDD under Type and click OK. You will get Tue in your cell.</p><p class="j">Another, probably safer way is to reference the date cell (e.g., =A1) and format this cell with a custom number format of DDD or DDDD. The big advantage to this method is that it leaves our true underlying date as a valid Excel date.<br>&nbsp;</p><h3>Return the Weekday as Weekday Text</h3><p class="j">If you won't be using the weekday that is returned in any further calculations, you can use either of the three formulas that follow (TEXT, WEEKDAY with CHOOSE) to return the weekday of a date as text.</p><p class="j">This formula assumes you have a valid date of 31-Jul-2007 n cell A1:<br>=TEXT(A1,&quot;DDDD&quot;) </p><p class="j">will produce Tuesday, or you could hard code your formula like:<br>=TEXT(&quot;31 Jul 2007&quot;,&quot;DDDD&quot;)</p><p class="j"><br>you could use the slightly longer CHOOSE function to get the same result:<br>=CHOOSE(WEEKDAY(A1),&quot;Sunday&quot;,&quot;Monday&quot;,&quot;Tuesday&quot;,&quot;Wednesday&quot;,&quot;Thursday&quot;,&quot;Friday&quot;,&quot;Saturday&quot;)</p><p class="j">and finally, you can hard code the date in the CHOOSE and nest the WEEKDAY function within it like:</p><p class="j">=CHOOSE(WEEKDAY(&quot;31 July 2007&quot;),&quot;Sunday&quot;,&quot;Monday&quot;,&quot;Tuesday&quot;,&quot;Wednesday&quot;,&quot;Thursday&quot;,&quot;Friday&quot;,&quot;Saturday&quot;) &quot;)</p><p class="j">All of these formulas will return the same result - Tuesday, remember though the underlying value of your cell will still be 31-Jul-2007, even though your cell reads Tuesday.</p></body></html>

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!