1 Reply Latest reply on Feb 7, 2012 10:03 AM by philmodjunk

    Return Dates as in eg. the First Thursday in December

    KevinO'Neill

      Title

      Return Dates as in eg. the First Thursday in December

      Post

      Greetings

      Can anyone tell me what calculation expressions I would use to return the day and date of the first Thusday of a given month?

      We have a lot of meetings that occur in that fashion. eg. 1st Monday of the month, 1st and 3rd Thursday's of the month, 2nd and 4th Tuesdays, etc., 

      Thank you

        • 1. Re: Return Dates as in eg. the First Thursday in December
          philmodjunk

          First Sunday:

          Let ( [D = Datefield ;                                                                  // any date in the month where you want the date for the first Sunday
                   MnthFirst = D - Day ( D ) + 1;                                          //date of first day of the month
                   Sunday1 = MnthFirst - dayOfweek ( MnthFirst) + 1 ] ;  //Sunday preceding or on first day of the month
                   Sunday1 + 7 * ( MnthFirst > Sunday1 )                          //add 7 days if 1st day of month is not a Sunday
                 )

          First Thursday:

          Let ( [D = Datefield ;                                                                    // any date in the month where you want the date for the first Sunday
                   MnthFirst = D - Day ( D ) + 1;                                            //date of first day of the month
                   Thursday1 = MnthFirst - dayOfweek ( MnthFirst) + 5 ] ;  //Thursday preceding or on first day of the month
                   Thursday1 + 7 * ( MnthFirst > Thursday1 )                       //add 7 days if 1st day of month is not a Thursday
                 )

          Note that the only difference btween First Sunday and First Thursday is the number added in the 3rd line so a single calculation could be set up to calculate any "first day of the month" needed.