How to get the previous day, the first day of the month, the last day of the month, and the number of days in the month.

03/07/2024

Japanese version.

Steps

In this example, the target date of the flow execution is retrieved.

However, it can be applied to any other date by changing the date used for the action.

The date can be text in yyyy-MM-dd format.

Previous day

Set up a "Subtract from time" action and configure it as follows.

ParameterValue
Base timeTarget date and time.
Interval1
Time unitDay

First day of the month

Set up a "Convert time zone" action and configure it as follows.

End of Month Day

The first step is to create the first day of the month for the following month.

Set up an "Add to time" action and configure it as follows.

ParameterValue
Base timeFirst day of the month.
Interval1
Time unitMonth

The dynamic content "Calculated Time" in "Add to time" will be on the first day of the next month.

Then set up "Subtract from time" and set as follows.

ParameterValue
Base timeFirst day of the next month.
Interval1
Time unitDay

The dynamic content "Calculated Time" in "Subtract from time" is the last day of the month.

Number of days in month

Use the month end date created in the previous step.

Set up "Initialize variable" and configure as follows.

ParameterValue
TypeInteger
Value@dayOfMonth(body('Subtract_from_time'))

For those who want to learn Power Automate Cloud flow effectively

The information on this site is now available in an easy-to-read e-book format.

Or Kindle Unlimited (unlimited reading).

You willl discover how to about basic operations.

By the end of this book, you will be equipped with the knowledge you need to use Power Automate Cloud flow to streamline your workflow.

Links

Tips.(Power Automate Cloud flows)