cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

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
Highlighted
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
Highlighted
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

Highlighted
Super User
Super User

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

Highlighted
Frequent Visitor

Re: Get certain day of month

This is great but how do you exclude weekends? 

Highlighted
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.

Highlighted
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

Highlighted
Helper IV
Helper IV

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?

Highlighted
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

Highlighted
Helper IV
Helper IV

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
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,863)