cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DAVIDPOWELL
Post Prodigy
Post Prodigy

Calculate working days from todays date from a variable in hours

I need a label or textbox to display

from a calculation so many days from todays date based on a hour value("dwn_Tasks.Selected.ServiceLevel_hours") in a dropdown

Excluding weekends

(8 hour working day)

So if the value from the dropdown is 72 hours(4 days)from todays date ;

the date displayed would be   2020-7-13  yyyy-m-d

 

Thanks

Dave

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @DAVIDPOWELL ,

 

I feel confused with your requirement:

Why do 72 hours mean 4 days? Is it a mistake

What is the start day of the week? Sunday, isn't it?


If my assumption is right, Please try to set the Text property of label as follows,

Text(
    DateAdd(
        Now(),
        dwn_Tasks.Selected.ServiceLevel_hours/24 + 2 * If(
            (Weekday(
                Now(),
                StartOfWeek.Sunday
            ) + dwn_Tasks.Selected.ServiceLevel_hours/24) > 5,
            RoundDown(
                (dwn_Tasks.Selected.ServiceLevel_hours/24 - (5-Weekday(
                    Now(),
                    StartOfWeek.Sunday
                ))) / 5,
                0
            ) + 1
        )
    ),
    "[$-en-US]yyyy-m-d"
)

Snipaste_2020-07-08_15-23-19.png

Hope this helps.

Sik

 

 

View solution in original post

4 REPLIES 4
JayMagness
Solution Specialist
Solution Specialist

v-siky-msft
Community Support
Community Support

Hi @DAVIDPOWELL ,

 

I feel confused with your requirement:

Why do 72 hours mean 4 days? Is it a mistake

What is the start day of the week? Sunday, isn't it?


If my assumption is right, Please try to set the Text property of label as follows,

Text(
    DateAdd(
        Now(),
        dwn_Tasks.Selected.ServiceLevel_hours/24 + 2 * If(
            (Weekday(
                Now(),
                StartOfWeek.Sunday
            ) + dwn_Tasks.Selected.ServiceLevel_hours/24) > 5,
            RoundDown(
                (dwn_Tasks.Selected.ServiceLevel_hours/24 - (5-Weekday(
                    Now(),
                    StartOfWeek.Sunday
                ))) / 5,
                0
            ) + 1
        )
    ),
    "[$-en-US]yyyy-m-d"
)

Snipaste_2020-07-08_15-23-19.png

Hope this helps.

Sik

 

 

View solution in original post

@v-siky-msft,

Sunday may be the first day of the week, but is not considered a workday. Nor Saturday.

 

But thanks will test the formula.

 

Dave

Great! and thanks. I can work with this.

dave

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,657)