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

 

 

@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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,335)