Forum Discussion
Expression.Error in nested "if" statements
- 7 years ago
Hi Anonymous,
remove the part with "ServiceTime =" before empty duration.
(StartDate as datetime, EndDate as datetime) as duration => let <variable declaration> ServiceTime = if ( <statement that returns "false" if the ServiceTime needs to be calculated> ) then (
ServiceTime =#duration(0,0,0,0)Next point is
#duration(C_ServiceTimeInDays - C_StartDateIsWorkDay - C_EndDateIsWorkDay)
which is definitely not correct, just use C_ServiceTimeInDays - C_StartDateIsWorkDay - C_EndDateIsWorkDay.
Btw. a similar task has been solved in Date / Time difference excluding weekends and factoring working ours, you can also inspire also there.
Hi Anonymous,
remove the part with "ServiceTime =" before empty duration.
(StartDate as datetime, EndDate as datetime) as duration => let <variable declaration> ServiceTime = if ( <statement that returns "false" if the ServiceTime needs to be calculated> ) then (ServiceTime =#duration(0,0,0,0)
Next point is
#duration(C_ServiceTimeInDays - C_StartDateIsWorkDay - C_EndDateIsWorkDay)
which is definitely not correct, just use C_ServiceTimeInDays - C_StartDateIsWorkDay - C_EndDateIsWorkDay.
Btw. a similar task has been solved in Date / Time difference excluding weekends and factoring working ours, you can also inspire also there.
Thanks for pointing me to that thread!
I was able to adapt this to my needs, also leveraging some of what I did in my formula.