
Announcements
Hey All,
Just had a query regarding using Date Expressions in Power Automate Desktop. I have a step within my flow which gets my Current Date and Time. I want to go one month back and return the date that is the first day of that particular month and return date that is the last date of the month.
I would be able to use expression on Cloud Flow simply by using startdate and enddate formula. However, I am not being able to recreate this in PAD. Was wondering if anyone could help?
Hi @Imrans23
No direct functions available in PAD but you can copy-paste the below code in PAD to get the desired results using vbscript.
DateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateOnly CurrentDateTime=> CurrentDateTime
DateTime.Add DateTime: CurrentDateTime TimeToAdd: -1 TimeUnit: DateTime.TimeUnit.Months ResultedDate=> ResultedDate
System.RunVBScript VBScriptCode: $'''varLastdate = DateSerial (%CurrentDateTime.Year%, %CurrentDateTime.Month%, 0)
WScript.Echo varLastdate
''' ScriptOutput=> LastDay ScriptError=> ScriptError
System.RunVBScript VBScriptCode: $'''varFirstDate = DateSerial (%ResultedDate.Year%, %ResultedDate.Month%, 1)
WScript.Echo varFirstDate
''' ScriptOutput=> FirstDay ScriptError=> ScriptError
Display.ShowMessage Message: $'''The first date of previous month is: %FirstDay%
The last date of previous month is: %LastDay%''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
PS: You will get more help on Power Automate Desktop in its dedicated page here.