cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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

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
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

 

  

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Top Kudoed Authors
Users online (4,451)