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

Notifications

Announcements

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
    12,982 Super User 2025 Season 2 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,974 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,479 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard