Assuming that you can exclude "working over the weekend" (see my previous reply), you first determine the 'legal' start and legal end of the working period:
StartPeriod = max(StartDate, <Sunday 23:00h>) - so whatever is higher will be used as start.
EndPeriod = min(EndDate, <Friday 23:00h>) - so whatever is lower will be used as end.
Period = EndPeriod - StartPeriod. - and this will give you the hours.
Of course the above is not QV code but gives you the idea. For max() (used in many programming languages) you can use NumMax() or RangeMax() in QV, and for min() you can use NumMin() or RangeMin() in QV.
Thanks for your comment. I have StartDate and EndDate. CycleTime should be counted as amount of hours, but only beetween Sunday 23:00 till Friday 23:00 (so 1 hours from Sunday, Mon, Tue, Wed, Thu, and 23 hours from Friday).For example if task start and end time is on Saturday CycleTime should be 0
I have to also exclude bank holidays
Below I attached example of dates which I have:
I havent found solution yet, so if somebody has any idea or clue I would really appreciate help