Shantha Kumar T
How to Get Last Date of the Month using Power Automate
Power Automate offer extensive automation capabilities, but working with DateTime functionalities can be challenging. In this blog, we’ll explore various methods and options to determine the last date of the month.
First, create a new Instant Cloud Flow. Next, add a Date input within the trigger, allowing the user to select a date whenever the workflow is triggered. Name this input variable as ‘date‘. For example, the selected Date is 2024-05-15
Method 1:
Next, add a Compose action to the workflow and use one of the expression listed below.
addDays(startOfMonth(addToTime(triggerBody()?['date'],1,'Month')),-1)
addSeconds(startOfMonth(addToTime(triggerBody()?['date'],1,'Month')),-1)
addMinutes(startOfMonth(addToTime(triggerBody()?['date'],1,'Month')),-1)
addHours(startOfMonth(addToTime(triggerBody()?['date'],1,'Month')),-1)
Method 2:
Base Time |
triggerBody()?[‘date’]
|
Interval | 1 |
Time Unit | Month |
Next, add the ‘Subtract from time‘ action and fill the below properties
Base Time |
startOfMonth(body(‘Add_to_time’))
|
Interval | 1 |
Time Unit | Day |
After running the workflow, it will product the following ouput,