cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rocko
Frequent Visitor

Setting variable values

Is there a way to set a variable to a value using a function or formula in PAD?  For example, I want to create a variable named BeginDate that is set to the first day of the previous month and then another variable named EndDate to be the last day of the previous month.  These would then be used to pass to a reporting application as the date range to run report with.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

Rocko,

You can accomplish this in PAD.

1. Get current date

2. Last day of the prev month = current date - day number

3. New date = current date - 1 month

3. First day of the previous month =  new date - day number + 1

 

GanCW_1-1613037778737.png

 

 

View solution in original post

7 REPLIES 7
Henrik_M
Super User
Super User

No. There are no functions or formulas. You need to do it with actions. Try pasting this code into your flow:

 

Display.SelectDate DateDialogFormat: Display.DateDialogFormat.DateOnly IsTopMost: True SelectedDate=> SelectedDate
Text.ToDateTime Text: $'''01-%SelectedDate.Month%-%SelectedDate.Year%''' DateTime=> TextAsDateTime
DateTime.Add DateTime: TextAsDateTime TimeToAdd: -1 TimeUnit: DateTime.TimeUnit.Days ResultedDate=> EndDate
Text.ToDateTime Text: $'''01-%EndDate.Month%-%EndDate.Year%''' DateTime=> BeginDate
Rocko
Frequent Visitor

Thank you for the reply. I am new to Power Automate/PAD and struggling to try to get what I think are basic things to work.  I am currently evaluating this tool as a cheaper option than my current RPA solution.

 

Where exactly would I paste this code?  I am working entirely in the desktop app.  All the searching I have done has shown using functions/expressions in the web interface.  Am I even wrong in assuming that everything can be done in the desktop app? I am on the verge of giving up and just writing this off as being overly complex compared to my current tool.  As an example, my current tool already has predefined date variables ("FirstDayPriorMonth", "LastDayPriorMonth",etc).  All I have to do is send those as inputs to my SSRS report parameters and then have it click "View Report" and all is good.  

 

Thanks again for the help!

sakula1996
Responsive Resident
Responsive Resident

Hi @Rocko , you can directly paste the @Henrik_M  code in PAD development canvas.

It will convert the above code to PAD actions.

 

sakula1996_0-1612733080603.png

 

Hope this helps 🙂

 

Rocko
Frequent Visitor

 

Thanks again Henrick_M....this gets me half way there.  The End Date (last day of prior month) is the same as the Begin Date.  I have done my best to figure out how to manipulate the logic you provided but I am not having any luck.

 

Rocko_0-1612793827285.png

 

@sakula1996 ,

How to get to this development canvas ?

Rocko,

You can accomplish this in PAD.

1. Get current date

2. Last day of the prev month = current date - day number

3. New date = current date - 1 month

3. First day of the previous month =  new date - day number + 1

 

GanCW_1-1613037778737.png

 

 

Rocko
Frequent Visitor

Thank you GanCW!  This got me what I was looking for.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Top Kudoed Authors
Users online (1,778)