web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Trying to get the firs...
Power Automate
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)
)
 
Categories:
I have the same question (0)
  • Suggested answer
    David_MA Profile Picture
    14,090 Super User 2026 Season 1 on at
    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.
  • takolota1 Profile Picture
    4,980 Moderator on at
     
    Basically it generates a dates table in a JSON array & then you can filter to whatever date you want using Filter array actions.
  • lbendlin Profile Picture
    8,649 Super User 2026 Season 1 on at
    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)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard