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 / How to pull the start ...
Power Automate
Unanswered

How to pull the start and end date of a list of dates in the format: (Start date - End Date)?

(0) ShareShare
ReportReport
Posted on by 166

Hi, 

 

I want to create a recurring flow that sends at the start of every Monday that sends an email to myself of the employee's who are off the this specific week. Sunday - Saturday

 

In the data I have - I do not have a start and end date it just shows a list of dates that have been approved e.g.

DynamicsHS_0-1660866383002.png

In the email I want the dates to show as:

Employee A: 15/08/2021 - 19/08/2021

Employee B: 16/08/2021 - 17/08/2021

 

Is it possible to capture the dates like this without including all the dates in-between? 

 

I do not want it do show like a string where it says:

[Employee A - 15/08, 16/08, 17/08, etc]

 

Thank you, 

Henry

Categories:
I have the same question (0)
  • Verified answer
    MarconettiMarco Profile Picture
    3,812 Super User 2024 Season 1 on at

    Hello @DynamicsHS ,

    please follow these steps:

    1. Initialize a String variable, that will be useful to list the Employees in the email body:

    MarconettiMarco_0-1660892835159.png

     

    2. Initialize a temporary Array variable, to be used to list the dates as numbers and find min and max values:

    MarconettiMarco_1-1660892880215.png

     

    3. Initialize an Integer variable, to store the min value:

    MarconettiMarco_2-1660892917901.png

    4. Initialize an Integer variable to store the max value:

    MarconettiMarco_3-1660892954932.png

    5. Add the Excel "List rows present in a table" in order to grab the Employees rows:

    MarconettiMarco_4-1660892992135.png

    6. Add a "Select" action where we want to extract the Employee from the previous array:

    MarconettiMarco_5-1660893014204.png

    7. Add a "Compose" action in which put the following expression, useful to get only unique values from the Select outputs action:

    union(body('Select'),body('Select'))

    MarconettiMarco_6-1660893097499.png

    8. Add an "Apply to each" control where add the following actions. The "Select an output from previous steps" field must be filled with the previous Compose outputs action:

    MarconettiMarco_7-1660893128688.png

    In the "Apply to each" settings it's needed to enable the "Concurrency control" and set it to 1.

    MarconettiMarco_19-1660894044894.png

     

    MarconettiMarco_18-1660894018975.png

     

    9. Add a "Filter array" action where we want to filter the excel rows based on the employee name:

    MarconettiMarco_8-1660893210680.png

     

    10. Add a "Parse JSON" action, in the "Content" field put the Filter array Body. In regards of the Schema section, please first run the flow, copy the Filter array outputs, then click on the "Generate from sample" button and paste the code inside.

    MarconettiMarco_9-1660893235488.png

    11. Add an Apply to each loop, putting the Parse JSON Body. Inside the Apply to each control, add the "Append to array variable", in the Value add the following expression in order to convert the string date in an integer:

    int(items('Apply_to_each_2')['Date'])

    MarconettiMarco_10-1660893381006.png

    12. Add a "Set variable" action where select the varMin variable and add the following expression:

    min(variables('varNumbers'))

    MarconettiMarco_11-1660893494713.png

    13. Add a "Compose" action putting the following expression, useful to identify the min date from an integer:

    addDays('1900-01-01',variables('varMin'),'yyyy-MM-dd')

    MarconettiMarco_12-1660893553758.png

    14. Add a "Set variable" action where select the varMax variable and add the following expression:

    max(variables('varNumbers'))

    MarconettiMarco_13-1660893638679.png

    15. Add a "Compose" action putting the following expression, useful to identify the max date from an integer:

    addDays('1900-01-01',variables('varMax'),'yyyy-MM-dd')

    MarconettiMarco_14-1660893707884.png

    16. Add the "Set variable" action, in order to set the temporary variable empty:

    []

    MarconettiMarco_15-1660893769281.png

    17. Add an "Append to string variable" action in order to populate the varEmployee variable:

    add the Current item: outputs from Compose-MinDate - outputs from Compose-MaxDate followed by the "<br>" code:

    MarconettiMarco_16-1660893802947.png

    18. Outside the Apply to each control, add a "Send an email (V2) action, in the email body add the "varEmployee" variable.

    MarconettiMarco_17-1660893901667.png

    If I have answered your question, please mark my post as Solved.
    If you like my response, please give it a Thumbs Up.

    BR,

    Marco

     

     

     

     

     

     

     

     

  • Henry G Smith Profile Picture
    166 on at

    @MarconettiMarco .....Wow, so in-depth. Thank you so much! 

     

    You sir are a legend. 

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

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard