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
Super User
Super User

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

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