web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Answered

Future date formula

(0) ShareShare
ReportReport
Posted on by 138

Hi, I need to enter the date of the last day of the current month in a date field, from any day in the current month, in dd/mm/yyyy format.

Can someone provide the formula for the variable?   

  • Verified answer
    VJR Profile Picture
    7,635 on at

    Option #1: Using PAD Actions

    - Paste the below code into a blank PAD editor and run the Flow

     

     

    Display.SelectDateDialog.SelectDate Message: $'''Select date of current month''' DateDialogFormat: Display.DateDialogFormat.DateOnly IsTopMost: False SelectedDate=> SelectedDate ButtonPressed=> ButtonPressed
    DateTime.Add DateTime: SelectedDate TimeToAdd: 1 TimeUnit: DateTime.TimeUnit.Months ResultedDate=> NextMonthDate
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: NextMonthDate CustomFormat: $'''01/MM/yyyy''' Result=> FirstDateNextMonth
    Text.ConvertTextToDateTime.ToDateTimeCustomFormat Text: FirstDateNextMonth CustomFormat: $'''dd/MM/yyyy''' DateTime=> FirstDateNextMonth
    DateTime.Add DateTime: FirstDateNextMonth TimeToAdd: -1 TimeUnit: DateTime.TimeUnit.Days ResultedDate=> LastDateOfMonth
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: LastDateOfMonth CustomFormat: $'''dd/MM/yyyy''' Result=> LastDateOfMonth
    Display.ShowMessageDialog.ShowMessage Message: LastDateOfMonth Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
    

     

     

     

     

    - The Pseudo logic is:

    • Take the Input Date eg; 28/07/2022
    • Add 1 month to it - 28/08/2022
    • Using the above date create the first date - 01/08/2022
    • Subtract 1 day from the above date - 31/07/2022
    • Final answer:31/07/2022
    • Rest all are date formatting actions.

     

    - This is how the process looks like if you select today's date

    VJR_0-1658977731322.png

     

       

    Option #2: Using vbscript

    If you are looking for a 1 liner approach use vbscript

     

    VJR_1-1658978461391.png

     

    PAD code with Vbscript

     

     

    Display.SelectDateDialog.SelectDate Message: $'''Select date of current month''' DateDialogFormat: Display.DateDialogFormat.DateOnly IsTopMost: False SelectedDate=> SelectedDate ButtonPressed=> ButtonPressed
    Scripting.RunVBScript VBScriptCode: $'''varLastdate = DateSerial (%SelectedDate.Year%, %SelectedDate.Month + 1%, 0)
    WScript.Echo varLastdate
    ''' ScriptOutput=> LastDate ScriptError=> ScriptError
    Display.ShowMessageDialog.ShowMessage Message: $'''
    The last date is: %LastDate%''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
    

     

     

     

     

  • garthh Profile Picture
    138 on at

    VJR thank you

    Makes sense now but beyond a newbie to work out before! 

  • garthh Profile Picture
    138 on at

    VJR, I made what I believe is a simple flow to work out the date needed

     

    The subflow DirecrDebitReportDate below calculates the date I need to the variable FormattedDateTime2.

    The Action Populate Tex tfield in window populates the Report parameters date field

    However the date is not FormatteddateTime2

    Where have I gone wrong?

    garthh_0-1659221122584.png

     

  • VJR Profile Picture
    7,635 on at

    Hi @garthh 

     

    VJR_0-1659326359739.png

     

    VJR_1-1659326373483.png

     

    Do some double checks whether the selectors are correct and/or whether the Flow is writing to the correct place in the combobox ie starting from the date and not from the year location of the box (ie; at the end).

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 430

#2
11manish Profile Picture

11manish 341 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 282

Last 30 days Overall leaderboard