+ Reply to Thread
Results 1 to 10 of 10

Calculating Dates

Hybrid View

StevenAlberta Calculating Dates 07-05-2012, 06:12 PM
jeffreybrown Re: Calculating Dates 07-05-2012, 06:22 PM
StevenAlberta Re: Calculating Dates 07-05-2012, 06:47 PM
daddylonglegs Re: Calculating Dates 07-05-2012, 07:09 PM
StevenAlberta Re: Calculating Dates 07-06-2012, 06:55 PM
jeffreybrown Re: Calculating Dates 07-06-2012, 06:57 PM
StevenAlberta Re: Calculating Dates 07-06-2012, 07:04 PM
jeffreybrown Re: Calculating Dates 07-06-2012, 07:05 PM
StevenAlberta Re: Calculating Dates 07-06-2012, 07:12 PM
daddylonglegs Re: Calculating Dates 07-06-2012, 07:16 PM
  1. #1
    Registered User
    Join Date
    06-12-2012
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    24

    Calculating Dates

    I am trying to find an easy way to have Excel calculate dates. For example, I want to calculate the date of Columbus Day. It is the 2nd Monday in October. How do I find the 2nd Monday in October?

    Thanks, Steven

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Calculating Dates

    Does this work for you?

    http://www.tek-tips.com/faqs.cfm?fid=7549

    Formula: copy to clipboard
    =DATE(YEAR(TODAY()),10,CHOOSE(WEEKDAY(DATE(YEAR(TODAY()),10,1)),9,8,14,13,12,11,10))
    Last edited by jeffreybrown; 07-05-2012 at 06:32 PM.
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    06-12-2012
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Calculating Dates

    I am looking for something where, within my formula, I can input the year, month, weekday and the weekdays position within the month (3rd Mon). For example, I want to find the 3rd Mon in July 2014.

    Any ideas.

    Thanks, Steven

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,720

    Re: Calculating Dates

    generically you can use this formula

    =DATE(yr,mon,1+pos*7)-WEEKDAY(DATE(yr,mon,8-day))

    where yr = year, mon = month, pos = position (1,2,3 or 4) and day = day of week Sun =1 through to Sat =7

    So for your example Columbus Day this year would be

    =DATE(2012,10,1+2*7)-WEEKDAY(DATE(2012,10,8-2))

    which gives you Monday 8th October 2012

    ...or 3rd Monday in July 2014

    =DATE(2014,7,1+3*7)-WEEKDAY(DATE(2014,7,8-2))

    which gives you Monday 21st July 2014

    If you want the last Monday in a month then find the first Monday in the next month and subtract 7
    Audere est facere

  5. #5
    Registered User
    Join Date
    06-12-2012
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Calculating Dates

    Thanks for the code. It works great but I am having problems altering the code to find the last day of Week for a particular month. For example, to find the last Monday in May. How would I do that.

    Thanks, Steven

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Calculating Dates

    Hi Steven,

    Did you see this part?

    Quote Originally Posted by daddylonglegs View Post
    If you want the last Monday in a month then find the first Monday in the next month and subtract 7
    Try

    Formula: copy to clipboard
    =DATE(2012,6,1+1*7)-WEEKDAY(DATE(2012,6,8-2))-7
    Last edited by jeffreybrown; 07-06-2012 at 07:02 PM.

  7. #7
    Registered User
    Join Date
    06-12-2012
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Calculating Dates

    Yes. I have tried the following but does not work:


    =DATE(yr,mon + 1,1+1*7)-WEEKDAY(DATE(yr,mon,8-day))-Day(7)

    I added one month to the month, exchanged the pos with 1 and subtracted 7 days.

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Calculating Dates

    Did you try the solution in post #6?

    It produces >> 5/28/2012 >> Monday

  9. #9
    Registered User
    Join Date
    06-12-2012
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Calculating Dates

    I found the problem. I was not adding one month to the Weekday part. It now works.

    Thanks so much,
    Steven

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,720

    Re: Calculating Dates

    You don't really need DAY(7) at the end [that could give you the wrong result in some circumstances] - better to just use 7

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1