cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JMAFO Advocate II
Advocate II

Get certain day of month

Hello everyone,

 

I'm building a Power Automate that needs to run on the 1st and 15th of the month and needs to get list items that fall between certain dates: 

 

First of month: day 16 of previous month - end of previous month

15th of month - 1st day of current month through 15th of current month

 

How can I do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Get certain day of month

Hi @JMAFO 

You will need to create a Flow with a Recurrence trigger that fires every day. The first action in your flow should be a Switch case where the item you are checking is the following Flow Expression.

 

dayOfMonth(utcNow())
 
You then need to add a case branch for the value 1 (1st day of month) and another for the value 15 (15th day of month). You should also have a default case which we will leave blank.
 
image.png
 
In the first case (1st of month) add the action to get list items. You can use the following Flow Expressions for the dates you need to check.
 

day 16 of previous month

addDays(startOfMonth(addDays(startOfMonth(utcNow()),-1)),16)

 

end of previous month

addDays(startOfMonth(utcNow()),-1)

 

Likewise for the case for the 15th day of the month, use the following Flow Expressions.
 
1st day of current month
startOfMonth(utcNow())
 
15th of current month

addDays(startOfMonth(utcNow()),15)

 

Hope that helps, if you get stuck using any of these expressions please post some screenshots of your errors.

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

View solution in original post

8 REPLIES 8
Super User
Super User

Re: Get certain day of month

Hi @JMAFO 

You will need to create a Flow with a Recurrence trigger that fires every day. The first action in your flow should be a Switch case where the item you are checking is the following Flow Expression.

 

dayOfMonth(utcNow())
 
You then need to add a case branch for the value 1 (1st day of month) and another for the value 15 (15th day of month). You should also have a default case which we will leave blank.
 
image.png
 
In the first case (1st of month) add the action to get list items. You can use the following Flow Expressions for the dates you need to check.
 

day 16 of previous month

addDays(startOfMonth(addDays(startOfMonth(utcNow()),-1)),16)

 

end of previous month

addDays(startOfMonth(utcNow()),-1)

 

Likewise for the case for the 15th day of the month, use the following Flow Expressions.
 
1st day of current month
startOfMonth(utcNow())
 
15th of current month

addDays(startOfMonth(utcNow()),15)

 

Hope that helps, if you get stuck using any of these expressions please post some screenshots of your errors.

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

View solution in original post

Re: Get certain day of month

@JMAFO - You can create a trigger that is "Scheduled". The scheduled trigger will allow you to choose when the flow would start.

 

Here is more info about scheduled triggers: https://docs.microsoft.com/en-us/power-automate/run-scheduled-tasks

Stuznet
Frequent Visitor

Re: Get certain day of month

This is great but how do you exclude weekends? 

Community Support
Community Support

Re: Get certain day of month

Hi @JMAFO ,

 

Please take a try with @LeeHarris 's solution and let me know if you have any problem.

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User
Super User

Re: Get certain day of month

Hi @Stuznet 

If you would like to exclude weekends, you can make use of the Flow Expression dayOfWeek(). Pass this a DateTime value and it will return an integer where Sunday is 0, Monday is 1 etc. You can use this in a condition action to perform certain actions on weekends.

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#d...

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

JMAFO Advocate II
Advocate II

Re: Get certain day of month

This worked beautifully. Thank you!

 

So I'm trying to generate a report, how would I make sure that both vacations starting in the time period and vacations ending in the time period are grabbed by the Get Items action?

Super User
Super User

Re: Get certain day of month

Hi @JMAFO 

Good to hear you got it working 😃👍

 

Without knowing the exact field names and syntax, it would probably be a filter along the lines of..

 

Get Items where...

(VacationStartDate greater than TimePeriodStartDate AND VacationStartDate less than TimePeriodEndDate ) OR (VacationEndDate greater than TimePeriodStartDate AND VacationEndDate less than TimePeriodEndDate)

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

JMAFO Advocate II
Advocate II

Re: Get certain day of month

I was on the cusp of figuring this part out and you solved the riddle. Your wizardry is truly unmatched! 

 

Thanks again! 

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (6,986)