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

Days calculate

Hello,

i need the Help from Community.

I have create a Flow for a Sharepoint list which should count the days between 2 dates.

Had here in the forum found a good example and this also readjusted.
It's the beginning of the flow. I have to finish it. Unfortunately I already got an error already. can someone tell me what i need to change

in_var2_Error.png

this is my Flow

Flow.png

Var_start.png

formatDateTime(triggerBody()?['EventDate'],'o')

 

var_end.png

formatDateTime(triggerBody()?['EndDate'],'o')

 

compose.png

addDays(variables('StartDate'),0,'MM/dd/yyyy')

 

Compose 2.png

addDays(variables('Enddate'),0,'MM/dd/yyyy')

 

Enddate.png

addDays(variables('Enddate'),0,'MM/dd/yyyy')

 

int_var.png

@{outputs('Compose')}

 

int_var2.png

@{outputs('Compose')}

 

do until.png

Compose 3: addDays(variables('IndexDate'),1,'MM/dd/yyyy')

Set variable 2: @{outputs('Compose_3')}

Append to array variable: @{variables('IndexDate')}

 

when the flow has passed, he should count the days together and the result determines whether an approval is necessary or not. that will come later. First, I have to fight the mistake.

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-yuazh-msft
Community Support
Community Support

Hi @pit850 ,

 

You couldn't initial an Array variable with a date directly.

 

Please take a try to initial an Array variable with null, and then append the date to the Array variable to achieve your needs, the screenshot should as below:

Capture.PNG

 

The flow would run successfully as below:

Capture.PNG 

 

Best regards,

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

pit850
Frequent Visitor

i have found the mistake.

the variable must be set outside the loop. I had them inside the loop and so it had the wrong value.
 
now running correct.

View solution in original post

3 REPLIES 3
v-yuazh-msft
Community Support
Community Support

Hi @pit850 ,

 

You couldn't initial an Array variable with a date directly.

 

Please take a try to initial an Array variable with null, and then append the date to the Array variable to achieve your needs, the screenshot should as below:

Capture.PNG

 

The flow would run successfully as below:

Capture.PNG 

 

Best regards,

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

First of all thanks for the help in the first step.

but now another problem has opened up. In my loop the days are to be counted which are present in the item.

check the index file with the enddate if equal to leave the loop.
Otherwise, run until condition is fulfilled and write the data into the array.

do until.png

so far so good. but if I check the content at the start of the loop is not the start date but it is increased by one value.

Thus, the loop test is not satisfied if it is only one day.

for Example: 

i create a Item with Startdate 03/07/2019

                               Enddate   03/07/2019

 

the content in the loop is then the indexdate 03/08/2019. Thus the flow runs endlessly.

I would like to count the contents of the array after the loop, if the content is less than or equal to 5 the flow should be terminated and the item created in the calendar. otherwise an approval should be started.
That works so far with a small restriction. It is always lost a day. Since the start date at the beginning already around.
 
What can i do.
best Regards
Peter

 

  

pit850
Frequent Visitor

i have found the mistake.

the variable must be set outside the loop. I had them inside the loop and so it had the wrong value.
 
now running correct.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,323)