+ Reply to Thread
Results 1 to 5 of 5

Comparing small timestamps in conditional formatting does not give expected result

  1. #1
    Registered User
    Join Date
    06-21-2017
    Location
    Luxembourg
    MS-Off Ver
    Office 2013
    Posts
    3

    Comparing small timestamps in conditional formatting does not give expected result

    Hi there,

    This is my first post here. I'm 36, from Luxembourg (Europe) and consider myself a Poweruser. I do a lot of VBA but I'm no IT guy.

    Anyway, I have a problem I am unable to solve.
    I'm working on a sheet which helps a manager of a Department to organize the shifts of his employees in the upcoming month. For every workday of the week, he puts in the start and endtime of the employees shift. Then, he can see if he assigned to many or to few work hours (based on a weekly due). This is done using conditional formatting. RED means not enough hours, GREEN means everytihng OK, YELLOW means too many hours assigned.

    This works almost perfectly. Indeed there is one employee who only works 1 hour a week. For him, even if the sum of the different days amounts to 1 hours, the sum field is displayed in red (as if he hadn't gotten enough hours assigned).

    I was able to reproduce this behaviour in a new Workbook. So my guess is, it has to do with the way Excel stores timestamps internally and not with the workbook itself.

    Here are some screenshots with explanations:

    Common explanations:
    In the first 2 rows I specify a start and end time for the shift (in this examples, the workweek has only 2 days, isn't that great :-)) The next column shows the time worked (simply $C2-$B2)
    Weekly due: this is a user inputed field in the format [hh]:mm. In my original file, this information comes from a different sheet. but for the purpose if this demonstration, I input the value by hand.
    Total worked: =SUM(D2:D3). Nothing fancy here.
    Diff: =D8-D7

    First screenshot. Expected result. Weekly due is 3:00. Total worked is 3:00. the field becomes green.
    Excel good formatting.png

    Second screenshot. Unexpected result. Weekly due is 1:00. Total worked is 1:00. So the field should be green. However, it is red (meaning total worked would be less than weekly due??)
    Excel wrong formatting.png

    Third screenshot: something weird I noticed: If I split the 1 hour from screenshot 2 over 2 days (1/2 hour per day, amounting to 1 hour total), the conditional formatting is as expected.
    Excel weird formatting.png

    I do really not know where this is coming from. The only reason I see would be the internal handling of timestamps. Excel does this as float IIRC? But why wouldn't this work? I hope someone can help me out here.

    If necessary, I can upload the xlsx somewhere.

    Regards.

  2. #2
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Comparing small timestamps in conditional formatting does not give expected result

    Welcome to the forum.

    Please upload your sample file so we can take a look at it.
    To do this, click 'Go Advanced' under the reply box, scroll down and look for the 'Manage Attachments' link. Click this to upload your file.
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  3. #3
    Registered User
    Join Date
    06-21-2017
    Location
    Luxembourg
    MS-Off Ver
    Office 2013
    Posts
    3

    Re: Comparing small timestamps in conditional formatting does not give expected result

    Thanks for your quick reply.

    I uploaded the sample document
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Comparing small timestamps in conditional formatting does not give expected result

    1hr = 0.41666666

    Its prob comparing 0.41666666 to 0.41667

    Perhaps use

    in D8
    =ROUND(SUM(D2:D3),7)
    or
    =TEXT(SUM(D2:D3),"hh:mm:ss")+0

    seems to cure the second screenshot problem
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  5. #5
    Registered User
    Join Date
    06-21-2017
    Location
    Luxembourg
    MS-Off Ver
    Office 2013
    Posts
    3

    Re: Comparing small timestamps in conditional formatting does not give expected result

    Thanks, that did the trick. I just had to also ROUND the value in D7.

    So I was kindof on the right track thinking about the floats. But I did not think about trying to round a "Time" value.

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 04-25-2017, 09:11 AM
  2. [SOLVED] condition formatting give the colour at the cell with the result
    By davide2574 in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 01-12-2016, 04:39 AM
  3. [SOLVED] why give me error #VALUE ... i need to give me the numbers from small to big
    By mena in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-22-2015, 10:11 AM
  4. [SOLVED] Not getting the expected results from conditional formatting
    By thoughtreactor in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-08-2015, 12:58 PM
  5. [SOLVED] Conditional formatting not working as expected
    By SEMMatt in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-25-2014, 09:53 PM
  6. Trimmed mean doesn't give expected result
    By Winton in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-03-2012, 06:31 AM
  7. Row-based conditional search to give a cumulative result
    By harsh2209 in forum Excel General
    Replies: 2
    Last Post: 03-13-2010, 09:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1