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

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (25,141)