i am trying to calculate the number of days between 2 dates/times using:
Solved! Go to Solution.
Hi,
Thank you for taking the time to reply to my issue, however formatting the date does not appear to work.
i have decided to go down another route and create a physical column in a list that will handle a complex calculatoin, then using the right connector i can pull the information through to the flow.
Calculation for working out weekdays between 2 dates:
=IF([Hours]>4,IF(AND((WEEKDAY([End Of Holiday],2))<(WEEKDAY([Start of Holiday],2)),((WEEKDAY([Start of Holiday],2))-(WEEKDAY([End Of Holiday],2)))>1),(((DATEDIF([Start of Holiday],[End Of Holiday],"D")+1))-(FLOOR((DATEDIF([Start of Holiday],[End Of Holiday],"D")+1)/7,1)*2)-2),(((DATEDIF([Start of Holiday],[End Of Holiday],"D")+1))-(FLOOR((DATEDIF([Start of Holiday],[End Of Holiday],"D")+1)/7,1)*2))),"0.5")
i have another column that calulates the same hours and using the above formula i have included a function to see if the hours column is less than 4 hours it will display 0.5 for a half day.
For simply calculateing week days between 2 dates the bold section could be removed, this may be able to be used within a flow but i have not tested it.
Hi @Damo_R,
Please try to first format the data to only date format and then calculate them using datediff. For your reference:
https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language
Regards,
Mona
Hi there,
I'm trying a similar expression which gives me this error:
The template validation failed: 'The template action 'Condition' at line '1' and column '1599' is not valid: "Unable to parse template language expression 'less(datediff(second, convertTimeZone(utcNow(), 1230, 1720), items('Apply_to_each')?['Project_x0020_Deadline']), 172800)'
All of the expression has already been covered above. Can you help me spot the error and remove it, @v-monli-msft?
Thanks,
Rachit B.
Hi,
Thank you for taking the time to reply to my issue, however formatting the date does not appear to work.
i have decided to go down another route and create a physical column in a list that will handle a complex calculatoin, then using the right connector i can pull the information through to the flow.
Calculation for working out weekdays between 2 dates:
=IF([Hours]>4,IF(AND((WEEKDAY([End Of Holiday],2))<(WEEKDAY([Start of Holiday],2)),((WEEKDAY([Start of Holiday],2))-(WEEKDAY([End Of Holiday],2)))>1),(((DATEDIF([Start of Holiday],[End Of Holiday],"D")+1))-(FLOOR((DATEDIF([Start of Holiday],[End Of Holiday],"D")+1)/7,1)*2)-2),(((DATEDIF([Start of Holiday],[End Of Holiday],"D")+1))-(FLOOR((DATEDIF([Start of Holiday],[End Of Holiday],"D")+1)/7,1)*2))),"0.5")
i have another column that calulates the same hours and using the above formula i have included a function to see if the hours column is less than 4 hours it will display 0.5 for a half day.
For simply calculateing week days between 2 dates the bold section could be removed, this may be able to be used within a flow but i have not tested it.
How do you do it for working hours between 2 dates (7.5 per day)?
Hi,
The above formula has since been adjusted and now calculates the hours between 2 dates excluding weekends based on serial hours.
=IF(OR([Start Of Holiday]="",[End Of Holiday]="",[End Of Holiday]<[Start Of Holiday],[End Of Holiday]=[Start Of Holiday]),"",IF(DATEDIF([Start Of Holiday],[End Of Holiday],"d")-(((DATEDIF([Start Of Holiday],[End Of Holiday],"d")+WEEKDAY([Start Of Holiday],3)-WEEKDAY([End Of Holiday],3))/7)*2)+1*(WEEKDAY([Start Of Holiday],3)>5)-(WEEKDAY([End Of Holiday],3)-4)*(WEEKDAY([End Of Holiday],3)>4)<0,0,IF(([End Of Holiday]-TRUNC([End Of Holiday])/1)-([Start Of Holiday]-TRUNC([Start Of Holiday])/1)>0.3,((DATEDIF([Start Of Holiday],[End Of Holiday],"d")-(((DATEDIF([Start Of Holiday],[End Of Holiday],"d")+WEEKDAY([Start Of Holiday],3)-WEEKDAY([End Of Holiday],3))/7)*2)+1*(WEEKDAY([Start Of Holiday],3)>5)-(WEEKDAY([End Of Holiday],3)-4)*(WEEKDAY([End Of Holiday],3)>4))+1),((DATEDIF([Start Of Holiday],[End Of Holiday],"d")-(((DATEDIF([Start Of Holiday],[End Of Holiday],"d")+WEEKDAY([Start Of Holiday],3)-WEEKDAY([End Of Holiday],3))/7)*2)+1*(WEEKDAY([Start Of Holiday],3)>5)-(WEEKDAY([End Of Holiday],3)-4)*(WEEKDAY([End Of Holiday],3)>4))+0.5))))
Basically if its a weekday and the difference in hours is less than 0.3 (serial hours) it will mark as half day. Over 0.3 is a full day
This should work for you also once you have replaced the column names.
Thanks Damo for your help.
Sorry it's not working for me. Showing few errors. Please see the screenshot for reference.
=IF(OR([Date_x0020_From]="",[Date_x0020_To]="",[Date_x0020_To]<[Date_x0020_From],[Date_x0020_To]=[Date_x0020_From]),"",IF(DATEDIF([Date_x0020_From],[Date_x0020_To],"d")-(((DATEDIF([Date_x0020_From],[Date_x0020_To],"d")+WEEKDAY([Date_x0020_From],3)-WEEKDAY([Date_x0020_To],3))/7)*2)+1*(WEEKDAY([Date_x0020_From],3)>5)-(WEEKDAY([Date_x0020_To],3)-4)*(WEEKDAY([Date_x0020_To],3)>4)<0,0,IF(([Date_x0020_To]-TRUNC([Date_x0020_To])/1)-([Date_x0020_From]-TRUNC([Date_x0020_From])/1)>0.3,((DATEDIF([Date_x0020_From],[Date_x0020_To],"d")-(((DATEDIF([Date_x0020_From],[Date_x0020_To],"d")+WEEKDAY([Date_x0020_From],3)-WEEKDAY([Date_x0020_To],3))/7)*2)+1*(WEEKDAY([Date_x0020_From],3)>5)-(WEEKDAY([Date_x0020_To],3)-4)*(WEEKDAY([Date_x0020_To],3)>4))+1),((DATEDIF([Date_x0020_From],[Date_x0020_To],"d")-(((DATEDIF([Date_x0020_From],[Date_x0020_To],"d")+WEEKDAY([Date_x0020_From],3)-WEEKDAY([Date_x0020_To],3))/7)*2)+1*(WEEKDAY([Date_x0020_From],3)>5)-(WEEKDAY([Date_x0020_To],3)-4)*(WEEKDAY([Date_x0020_To],3)>4))+0.5))))
My fields:
Date_x0020_From
Date_x0020_To
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!
User | Count |
---|---|
14 | |
14 | |
7 | |
6 | |
5 |
User | Count |
---|---|
24 | |
17 | |
10 | |
8 | |
6 |