+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : Refine a countif formula

  1. #1
    Registered User
    Join Date
    03-17-2010
    Location
    Fort Riley
    MS-Off Ver
    Excel 2010
    Posts
    37

    Refine a countif formula

    I am working on trying to get time down to seconds by using a DTG.

    Column A has inputs of: 17100932APR10 (17 the day 10:09:32 the Time)

    Column AN has the same input but different min and sec.

    What I want to capture is just the difference in the min and sec.

    this formula below works for the hours and min, I cannot seem to get it the way I want it.


    =IF(COUNTA(A15:AN15),REPLACE(AN15,3,5,"")+TEXT(MID(AN15,3,4),"00\:00")-REPLACE(A15,3,5,"")-TEXT(MID(A15,3,4),"00\:00"),"")
    Last edited by joesport5; 04-23-2010 at 12:09 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Refine a countif formula

    Maybe,

    =TIMEVALUE(MID(AN15,3,2)&":"&MID(AN15,5,2)&":"&MID(AN15,7,2))-TIMEVALUE(MID(A15,3,2)&":"&MID(A15,5,2)&":"&MID(A15,7,2))

    Regards

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,729

    Re: Refine a countif formula

    Try using this formula

    =IF(COUNTA(A15:AN15),TEXT(MID(AN15,3,6),"00\:00\:00")-TEXT(MID(A15,3,6),"00\:00\:00"),"")

    format result cell as mm:ss

    Assumes that that A15 and AN15 entries will always be on the same day.....

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,729

    Re: Refine a countif formula

    ......I note that in your original formula you are using this part

    REPLACE(AN15,3,5,"")

    ....to get the date without the time, but as the time is 6 digits in your example (and I assume there's always a leading zero when hours are 9 or less) that should be a 6 not a 5...so if you want to take a date change into account (as your original formula does) you could do that like this

    =IF(COUNTA(A15:AN15),REPLACE(AN15,3,6,"")+TEXT(MID(AN15,3,6),"00\:00\:00")-REPLACE(A15,3,6,"")-TEXT(MID(A15,3,6),"00\:00\:00"),"")

    or if the date change will only ever be to the next day you could do this

    =IF(COUNTA(A15:AN15),TEXT(MID(AN15,3,6),"00\:00\:00")-TEXT(MID(A15,3,6),"00\:00\:00")+(LEFT(A15,2)<>LEFT(AN15,2)),"")

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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