Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Finding the Previous Work Day.

Finding the Previous Work Day

by Allen Wyatt
(last updated January 18, 2014)

6

Joe wonders how to return the date of the previous work day, taking into account any holidays. He needs to be able to get this information for any particular date.

Excel has a number of functions and formulas that help automate obtaining routine information. The Analysis ToolPak add-on contains formulas that can help with these automations. One is the WORKDAY function.

Assuming you have the Analysis ToolPak enabled (how you do so has been covered in other issues of ExcelTips), you can obtain the date information you need by using the following formula:

=WORKDAY(A1,-1,MyHolidays)

The first part of this formula, A1, refers to the cell where the reference date is located. This information can be obtained in a couple of different ways. You can manually enter the date into cell A1 or you could use a formula in that cell to signify the date. For instance, you could use the following simple formula in cell A1 so that it always contains today's date:

=TODAY()

The second part of the formula, -1, says to subtract one day from the date in A1. The third part of the formula, MyHolidays, refers to a named range containing a list of dates and holidays you want skipped in determining the previous workday.

The WORKDAY function returns the date of day previous to the date entered in A1, allowing for any holidays.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8104) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Finding the Previous Work Day.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Checking for an Entry in a Cell

You may be looking for a way to have a formula determine if a particular cell has anything in it. Here's how you can find the ...

Discover More

Adjusting Comment Printouts

Need to print out comments, but in a way that you control what is included in the printout? Here's a way you can extract the ...

Discover More

Spacing Before and After Tables

Tables can be a necessity in many types of documents. However, they can be a bother to get positioned properly relative to ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (menu)

Converting UTC Times to Local Times

Dates and times are often standardized on UTC time, which is analogous to GMT times. How to convert such times to your local ...

Discover More

Pulling All Fridays

It can be handy to know when specific weekdays occur within a range of dates. Figuring out this information, using formulas, ...

Discover More

Setting a Default Date Format

Enter a date into a cell, and Excel allows you to format that date in a variety of ways. Don't see the date format you want? ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 2 + 1?

2017-04-21 17:40:23

Saralinda

Stan, I'd like the answer to that as well. I'm trying to get a date 30 days from the end of the month, but if that falls on a weekend or a holiday, I need the last work day prior. I almost have it, but Thanksgiving of 2013 is giving me issues. Thirty days out from October 31st is Saturday, November 30th.

If I put the calculations into separate columns, I can get the correct result, but I can't quite put all the coding from the different columns into one cell:

• Column A: EOM , Date in row 2 of 12,31,2012. Rest of cells in column have =EOMONTH(A2,1)
• Column B: =$A2+30
• Column C: =B2 + (COUNTIF(I$2:I$14,B2)*-1)
• Column D: =C2+CHOOSE(WEEKDAY(C2),-2,0,0,0,0,0,-1)
• Column E: =D2 + (COUNTIF(I$2:I$14,D2)*-1)
• Column F: =E2 + (COUNTIF(I$2:I$14,E2)*-1)
• Column G is simply shaded to break from the list of Holidays and the Holiday Calculation
• Column H is simply text name of Holiday (e.g. New Year Day)
• Column I is Holiday Calculation:
• =DATE(2013,1,1)
• 1/30/2013 (This was changed from =DATE(YEAR(TODAY()),1,1)+14+CHOOSE(WEEKDAY(DATE(YEAR(TODAY()),1,1)),1,0,6,5,4,3,2)
just for testing purposes)
• etc. In 2013, Thanksgiving falls on November 28th, and the Friday after falls on the 29th.

If somone can help me get the code from the different columns (A-F) into one cell, it would be greatly appreciated. Before I thought of Thanksgiving falling at the end of the month, I had:
=((A12+30) + (COUNTIF(E12:E24,(A12+30))*-1))+CHOOSE(WEEKDAY(((A12+30) + (COUNTIF(E12:E24,(A12+30))*-1))),-2,0,0,0,0,0,-1)
but I've had to add two more checks for holidays.

Thank you


2015-05-18 11:18:14

BryanW

@stan try this:

=IF(WEEKDAY(A1,2)>5,WORKDAY(A1,-1,Holidays),IF(COUNTIF(Holidays,A1),WORKDAY(A1,-1,Holidays),A1))

I use a slightly modified one that moves the day to Monday if the day in question falls on a Sunday.

=IF(WEEKDAY(A1,2)=6,WORKDAY(A1,-1,Holidays),IF(WEEKDAY(A1,2)=7,WORKDAY(A1,1,Holidays),IF(COUNTIF(Holidays,A1),WORKDAY(A1,-1,Holidays),A1)))


2015-01-28 16:50:48

mike

Stan wanted the previous workday , only if the current day is a weekend or holdiday. the above solution doesn't give the same day as requitred for mon to fri.

this should work

workday(current date +1, -1, myholidays)


2014-04-08 12:02:10

Stan Lieberman

Micky - 0) Thank you for responding
1) Weenend days are Saturday and Sunday
2) Holiday dates are in a worksheet named "Holidays" in the same workbook where I want to create the formula.
3) If the date in cell A1 is not a weekend or holiday I want the result to be the same date that is already in cell A1. (As further explanation, I have a rule that says, "If the due date is on a weekend or holiday the due date changes to the last workday before the original due date").
Thank you for your help.
Stan - Los Angeles, CA - USA


2014-04-08 07:01:20

Michael (Micky) Avidan

@Stan,1) What R the Weekend day(s) in your region ?
2) where did U put the Holiday(s) date(s) ?
3) If the date, in cell A1, is not a weekend - what do you expect as a result ?
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2014)
ISRAEL


2014-04-07 13:01:35

Stan Lieberman

I'm looking for a formula that will give me the previous workday ONLY IF THE DATE (in cell A1) FALLS ON A WEEKEND OR HOLIDAY (HOLIDAY AS DEFINED BY ME). Is there a way to do this?
Thank you.


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.