Calculating the First Tuesday

by Allen Wyatt
(last updated June 16, 2018)

6

Christine needs a way to calculate the first Tuesday of any given month. So, given a month and a year, she needs to get the date of that first Tuesday.

There are quite a few different formulas you can use to achieve the desired result. Most approaches use the WEEKDAY function in some way because it can return a numeric value representing the day of the week for any given date. Assuming that you put a month in cell A1 (1 through 12) and a four-digit year in cell A2, then the following formulas will all return a date for the first Tuesday in the month. (I've arranged the formulas in order of length, from longest to shortest.)

=DATE(A2,A1,1)+IF(WEEKDAY(DATE(A2,A1,1))=3,0,IF(WEEKDAY(DATE(A2,A1,1))>3,7-WEEKDAY(DATE(A2,A1,1))+3,3-WEEKDAY(DATE(A2,A1,1))))
=IF(3-WEEKDAY(DATE(A2,A1,1))>=0,DATE(A2,A1,1)+3-WEEKDAY(DATE(A2,A1,1)),DATE(A2,A1,1)+7+3-WEEKDAY(DATE(A2,A1,1)))
=DATE(A2,A1,1)+IF(3-WEEKDAY(DATE(A2,A1,1))>=0,3-WEEKDAY(DATE(A2,A1,1)),10-WEEKDAY(DATE(A2,A1,1)))
=DATE(A2,A1,1)-WEEKDAY(DATE(A2,A1,1),1)+3+IF(WEEKDAY(DATE(A2,A1,1),1)>3,7,0)
=DATE(A2,A1,1)+8-DAY(DATE(A2,A1,1))-WEEKDAY(DATE(A2,A1,1)-DAY(DATE(A2,A1,1))-2)
=DATE(A2,A1,1)+3-WEEKDAY(DATE(A2,A1,1))+(1-(3>=WEEKDAY(DATE(A2,A1,1))))*7
=DATEVALUE(A2&"/"&A1&"/1")+MOD(10-WEEKDAY(DATEVALUE(A2&"/"&A1&"/1")),7)
=DATE(A2,A1,MATCH(TRUE,WEEKDAY(DATE(A2,A1,{1,2,3,4,5,6,7}))=3,0))
=DATE(A2,A1,MOD(10-WEEKDAY(DATE(A2,A1,1)),7)+1)
=DATE(A2,A1,1)+MOD(3-WEEKDAY(DATE(A2,A1,1)),7)
=DATE(A2,A1,1)+7-WEEKDAY(DATE(A2,A1,1),13)
=DATE(A2,A1,8-WEEKDAY(DATE(A2,A1,1),13))
=DATE(A2,A1,7)-MOD(DATE(A2,A1,7)-3,7)
=DATE(A2,A1,8-WEEKDAY(DATE(A2,A1,5)))
=DATE(A2,A1,8)-WEEKDAY(DATE(A2,A1,5))

If you find it more convenient to specify a date within the month you want to evaluate, then you can modify the formulas to take that into account. The follow are just a few formulas you could use if you put an actual date into cell A1:

=DATE(YEAR(A1),MONTH(A1),MATCH(TRUE,WEEKDAY(DATE(YEAR(A1),MONTH(A1),{1,2,3,4,5,6,7}))=3,0))
=DATE(YEAR(A1),MONTH(A1),MOD(10-WEEKDAY(DATE(YEAR(A1),MONTH(A1),1)),7)+1)
=DATE(YEAR(A1),MONTH(A1),1)+MOD(3-WEEKDAY(DATE(YEAR(A1),MONTH(A1),1)),7)
=DATE(YEAR(A1),MONTH(A1),1)+7-WEEKDAY(DATE(YEAR(A1),MONTH(A1),1),13)
=DATE(YEAR(A1),MONTH(A1),8-WEEKDAY(DATE(YEAR(A1),MONTH(A1),1),13))
=DATE(YEAR(A1),MONTH(A1),7)-MOD(DATE(YEAR(A1),MONTH(A1),7)-3,7)
=DATE(YEAR(A1),MONTH(A1),8-WEEKDAY(DATE(YEAR(A1),MONTH(A1),5)))
=DATE(YEAR(A1),MONTH(A1),8)-WEEKDAY(DATE(YEAR(A1),MONTH(A1),5))
=A1-DAY(A1)+7-WEEKDAY(A1-DAY(A1)-1,3)

Finally, you may want to consider a macro-based approach. The following is a user-defined function that quickly figures out the first Tuesday:

Function FirstTuesday(M As Integer, Y As Integer) As Date
    Dim dResult As Date

    dResult = DateSerial(Y, M, 1)
    Do While Weekday(dResult) <> vbTuesday
        dResult = DateAdd("d", 1, dResult)
    Loop
    FirstTuesday = dResult
End Function

All you need to do in your worksheet is to pass the user-defined function the numeric month and year desired:

=FirstTuesday(6,2018)

If you prefer, you can specify that the month and year are in a cell:

=FirstTuesday(A2,A1)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13540) applies to Microsoft Excel 2007, 2010, 2013, and 2016.

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

Understanding Graphic Linking

Word provides a couple of different ways that graphics can be linked to your document. How you control the method used ...

Discover More

Bypassing the BeforeClose Event

Hold down the Shift key as you open a workbook, and Excel bypasses any "startup macros" that may be in the workbook. If ...

Discover More

Counting All Characters

Need to know how many characters there are in a workbook? You can find out easily with the handy macro introduced in this ...

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 (ribbon)

Specifying Different Weekends with NETWORKDAYS

The NETWORKDAYS worksheet function can be used to easily determine the number of work days (Monday through Friday) within ...

Discover More

Determining Month Names for a Range of Dates

Given a starting date and an ending date, you may want to generate the names of all the months between those two dates. ...

Discover More

Converting UNIX Date/Time Stamps

If you import information generated on a UNIX system, you may need to figure out how to change the date/time stamps to ...

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. Maximum image size is 6Mpixels. 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 four minus 0?

2018-06-20 14:38:58

Willy Vanhaelen

@Peter Atherton
Here is a much shorter formula to do the job:

=FLOOR(DATE(B2,B1,7-B4),7)+B4

(see Figure 1 below)

Figure 1. 


2018-06-20 09:19:40

Peter Atherton

Ignore the last post.

The following returns the first date for any workday.

=DATE(B2,B1,1)+ABS(7-WEEKDAY(DATE(B2,B1,1)+7-B4))

(see Figure 1 below)

Figure 1. 


2018-06-19 06:31:05

Peter Atherton

Willy

a variation on your smashing formula

=CEILING(DATE($B$2,$B$1,1+Rwkday),7)-(1+Rwkday) to find th first occurrunce

and
=(CEILING(DATE($B$2,$B$1,1+Rwkday),7)-(1+Rwkday)+7*(WkNumber-1)) to get the nth occurence

(see Figure 1 below)


Figure 1. 


2018-06-17 08:08:38

Willy Vanhaelen

@Erik
If you use my formula you get the same result:
=CEILING(DATE(B2,B1,5),7)-4
but it is half the size :-).


2018-06-16 21:59:51

Erik

If you input the month and year of interest in two cells, one short formula will tell you the date of the first Tuesday of that month.
For example:
• input your month (1-12) in cell B1
• input the four-digit year in cell B2
• use this formula: =DATE(B2,B1,1)+7-WEEKDAY(DATE(B2,B1,1),13)
Be sure the formula cell is formatted as a date so the result is legible.


2018-06-16 08:28:37

Willy Vanhaelen

Here is probably the shortest possible formula for the first approuch:

=CEILING(DATE(A2,A1,5),7)-4

As for the macro, here is a one-liner:

Function FirstTuesday(M As Integer, Y As Integer) As Date
FirstTuesday = Evaluate("CEILING(DATE(" & Y & " ," & M & ",5),7)-4")
End Function


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu 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.