• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Calculate SLA based on time formatted as [hh]:mm

Hi Guys,

I am stuck with a time format issue. I have a column containing time ([hh]:mm) based on which I want to calculate SLA's (YES/NO).

I am attaching a self explanatory macro based sheet for your reference.

Please suggest.
 

Attachments

  • calculate SLA based on time.xlsm
    131.5 KB · Views: 8
Change the line
from: dt_hr = Hour(Range("R" & i).Value)
to: dt_hr = Range("B" & i).Value * 24

What is happening is that Column B has Hrs and example B7 has 50:51
which is 2.11888888888643 days

for B7 The expression Range("R" & i).Value returns 2.11888
So simply multiply that by 24 to get 50.85 hrs and then do your checks
 
Change the line
from: dt_hr = Hour(Range("R" & i).Value)
to: dt_hr = Range("B" & i).Value * 24

What is happening is that Column B has Hrs and example B7 has 50:51
which is 2.11888888888643 days

for B7 The expression Range("R" & i).Value returns 2.11888
So simply multiply that by 24 to get 50.85 hrs and then do your checks

Hi Sir,

I have tried your suggestion but no help. :(
 
@Ehtisham Ali

FYI - You can't use Hour function on time greater than 24hrs. Well, you can, but it will return hour portion only and will ignore Day portion.

Ex. Hour("27:01") is extracting hour from 1 day 3 hours 1 min. Thus it will return 3 and not 27.

Hui's suggestion is the simplest way to deal with this issue. I tested it and result matched your criteria.
 
Back
Top