Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

Trying to get the first Tuesday of a specific month

(0) ShareShare
ReportReport
Posted on by

I've been trying to work a flow to send out an email for events that occur on a specific day of the month. However I cannot get the logic right, and flow keeps telling me the expression is invalid, and I cannot for the life of me see why.

Basically we have a event on the 1st tuesday of specific months, the idea is when someone submits a form, it replies with an email saying the next dates are the next 4 dates from today - I'm processing them into an array and ordering them in the email so it makes sense. I just can't seem to get the formula quite correct to calculate the date for each month.

 

I just get expression is invalid

 

addDays(
    startOfMonth(
        addToTime(
            utcNow(),
            if(greater(int(formatDateTime(utcNow(), 'MM')), 8), 12 - int(formatDateTime(utcNow(), 'MM')) + 8, 8 - int(formatDateTime(utcNow(), 'MM'))),
            'Month'
        )
    ),
    mod(9 - dayOfWeek(
        startOfMonth(
            addToTime(
                utcNow(),
                if(greater(int(formatDateTime(utcNow(), 'MM')), 8), 12 - int(formatDateTime(utcNow(), 'MM')) + 8, 8 - int(formatDateTime(utcNow(), 'MM'))),
                'Month'
            )
        )
    ), 7)
)
 
  • lbendlin Profile Picture
    7,943 Super User 2025 Season 1 on at
    Trying to get the first Tuesday of a specific month
    Remember that this data is immutable. You can simply prepare a list of the first tuesday of all the months in the next ten years and then check if your date is in the list.  (list=array)
  • takolota1 Profile Picture
    4,882 Super User 2025 Season 1 on at
    Trying to get the first Tuesday of a specific month
     
    Basically it generates a dates table in a JSON array & then you can filter to whatever date you want using Filter array actions.
  • Suggested answer
    David_MA Profile Picture
    11,512 Super User 2025 Season 1 on at
    Trying to get the first Tuesday of a specific month
    I am not sure I completely know how to achieve what you want, but I see where you are going with your expression. However, I might try starting it with this expression dayOfWeek(startOfMonth(utcNow())) instead. Knowing the day of the week the month started will help to determine the first Tuesday. dayOfWeek returns a number from 0 to 6 with 0 being Sunday and Saturday being 6. For August 2024, this returns 4 since it started on a Thursday. You would then know you need to add five days to this to get to the first Tuesday.
     
    Since you need the first Tuesday, you could use a switch on the outcome of the expression to set a variable for how many days you need to add to get to the first Tuesday.
    1. Sunday (0) add 2
    2. Monday (1) add 1
    3. Tuesday (2) add 0
    4. Wednesday (3) add 6
    5. Thursday (4) add 5
    6. Friday (5) add 4
    7. Saturday (6) add 3
    Of course, you will want to test this in case my math is off. And maybe you can figure out how to do it all with one expression.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492