cancel
Showing results for
Did you mean:
Helper I

## How to get the nth weekday for a month?

I've made a bit of progress in getting the 2nd Tuesday of the month, the 1st & 3rd Tuesday, and 2nd & 4th Tuesday. I found the formulas I've pieced together to sort of work.

I have a date picker for Committee A and another for Committee B which is held every 2nd Tuesday of the month. I'd like for the date populated in Committee A field to auto-populate Committee B with the second if the Tuesday month of the date in Committee A has not passed the 2nd Tuesday of the current month if it has, I'd like for it to populate Committee B field with the 2nd Tuesday in the upcoming month.

For the 2nd Tuesday of the month, I have the following Committee B DefaultDate:

This formula works only if the date in Committee A is BEFORE the 2nd Tuesday of the month, if it isn't, it just moves the date in Committee B field out a week.

I figure once I can get the 2nd Tuesday field figured out, it should relatively the same for the committees that are on the 1st and 3rd Tuesday of the month.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

Hi @ljkeefe

You can do this by adding an If statement - if the first Tuesday of the current month is greater than the date selected in CommitteeADatePicker, you would calculate the first Tuesday of the following month by adding a month.
This is the formula you would use.

``````With({FirstOfMonth:Date(Year(CommitteeADatepicker.SelectedDate),
DayOfWeek:3,
N:2
},
)},
),
FirstTuesday
)
)
) ``````

3 REPLIES 3
Super User

Hi @ljkeefe

You can do this by adding an If statement - if the first Tuesday of the current month is greater than the date selected in CommitteeADatePicker, you would calculate the first Tuesday of the following month by adding a month.
This is the formula you would use.

``````With({FirstOfMonth:Date(Year(CommitteeADatepicker.SelectedDate),
DayOfWeek:3,
N:2
},
)},
),
FirstTuesday
)
)
) ``````

Helper I

Thanks, @timl ! That works. I thought that I would be ok taking that syntax and modifying it for the 1st Tuesday and 3rd Tuesday of the month but it's not working. This is pretty similar to the previous scenario of the date computed in Committee B field is great than the 1st and 3rd Tuesday of the month, then it calculates to the first Tuesday of the next month. I'm pretty sure it's my IF statement.  Here's how I modified it:

Thank you for your help. I'm still relatively new to Power Apps, about four months now. It's amazing how much there is to learn. Thank you again.

Helper I

Never mind, I got it!

Thanks!!

Announcements

#### Launching new user group features

Learn how to create your own user groups today!

#### Community & How To Videos

Check out the new Power Platform Community Connections gallery!

#### Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,039)