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 / Get last day of the cu...
Power Automate
Answered

Get last day of the current month

(0) ShareShare
ReportReport
Posted on by 20

Hi Team,

 

How to get last day of the current month in power automate desktop?

 

Thanks 

 

 

I have the same question (0)
  • Verified answer
    Mowgli Profile Picture
    15 on at

    You could do something like this. (It's something that I used a long time ago)
    (Paste it into Pad)

     

    DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''dd''' Result=> FormattedDateTime
    Text.ToNumber Text: FormattedDateTime Number=> TextAsNumber
    DateTime.Add DateTime: CurrentDateTime TimeToAdd: $'''-%TextAsNumber - 1%''' TimeUnit: DateTime.TimeUnit.Days ResultedDate=> Firstdate
    DateTime.Add DateTime: Firstdate TimeToAdd: 1 TimeUnit: DateTime.TimeUnit.Months ResultedDate=> LastDate
    DateTime.Add DateTime: LastDate TimeToAdd: -1 TimeUnit: DateTime.TimeUnit.Days ResultedDate=> LastDayInMonth
    Display.ShowMessageDialog.ShowMessage Message: $'''First date of Month : %Firstdate%
    Last date of month : %LastDayInMonth%''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed

  • darshi_khirani Profile Picture
    2 on at

    Hi Mowgli I am struggling to get this but I didnt understand what to do 
    I want the first date of current month and the last day of the current month

    how do i get these two answers i saw you answer but i didnt understand where to paste the text

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Just paste it directly into the PAD flow designer and the actions will be automatically created for you.

  • Suggested answer
    CALEBHOWARD80 Profile Picture
    27 on at

    To solve this, you can break down the formula by focusing on the equals statement. Here’s how it looks:

    addDays(addToTime(startOfMonth(utcNow()), 1, 'Month'), -1)
    Explination:
    1. startOfMonth(utcNow()) - Gets the start of the current month.
    2. addToTime(..., 1, 'Month') - Moves to the start of the following month.
    3. addDays(..., -1) - Backs up by one day, giving you the last day of the current month.

     

    /////////////////////////////////////////////////////////////////////////////////

     

    I designed this formula to check if today is the last day of the month, but you can adapt it to check any day you want by changing -1 to the number of days from the end of the month you're interested in.

    Here’s the formula:

    equals(startOfDay(utcNow()), addDays(addToTime(startOfMonth(utcNow()), 1, 'Month'), -1))

    Explination:

    1. startOfMonth(utcNow()) - Finds the start of the current month.
    2. addToTime(..., 1, 'Month') - Moves to the start of the next month.
    3. addDays(..., -1) - Backs up one day, giving you the last day of the current month.
    4. equals(startOfDay(utcNow()), ...) - Checks if today is that date.

    For any other day near the end of the month, just adjust -1 to a different number.

    Let me know if you’d like more detail!


     
  • Suggested answer
    SaiRT14 Profile Picture
    1,990 Super User 2025 Season 2 on at
    try this out:
     
    CurrentDateTime = DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime
     
    FormattedDateTime = Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: "dd"
    TextAsNumber = Text.ToNumber Text: FormattedDateTime
     
    FirstDate = DateTime.Add DateTime: CurrentDateTime TimeToAdd: -TextAsNumber + 1 TimeUnit: DateTime.TimeUnit.Days
     
    LastDate = DateTime.Add DateTime: FirstDate TimeToAdd: 1 TimeUnit: DateTime.TimeUnit.Months
    LastDayInMonth = DateTime.Add DateTime: LastDate TimeToAdd: -1 TimeUnit: DateTime.TimeUnit.Days
     
    Display.ShowMessageDialog.ShowMessage Message: "First date of Month : %FirstDate% \nLast date of month : %LastDayInMonth%"
     
     

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard