+ Reply to Thread
Results 1 to 14 of 14

Extract minute value

  1. #1
    Registered User
    Join Date
    12-27-2014
    Location
    Rio Rancho, NM
    MS-Off Ver
    Office 2010
    Posts
    43

    Extract minute value

    All, I have a bunch of data that I need to assign to a shift.
    I have 4 shifts (Shifts: 4,5,6,7) and track work assignments based on the minute tasks fall on.
    So if task falls on at 19:04 or 7:04PM, it's a shift 4 task. 19:06, would be Shift 6, and so on.
    I did a simple "=MID([@[Due Time]],5,1)" wanting to extract 5th character based on "6:07:00 AM" string, but my results are inconsistent.

    Also, next step would be to highlight in red, any tasks that do not fall on the 4th, 5th, 6th or 7th minute as it would mean that they're not assigned to anyone of the existing shifts. I think I can do that with conditional formatting, but you all always seem to come up with new (to me) and creative formulas, so I figured I'd ask.
    Attached Files Attached Files
    Last edited by mariomp; 11-20-2017 at 11:40 PM.

  2. #2
    Registered User
    Join Date
    12-27-2014
    Location
    Rio Rancho, NM
    MS-Off Ver
    Office 2010
    Posts
    43

    Re: Extract minute value

    BTW, I also tried "=MINUTE([@[Due Time]])" but that didn't work either and returned all zeros.

  3. #3
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Extract minute value

    The times in column A are bona fide Excel time values. What you see (e.g. 7:00) is the result of a numeric format. The actual value is stored as a decimal fraction, namely 1/24 of a day.

    For example, what appears to be 7:00 in A2 is actually 0.291666666666667. That is why MID(A2,5,1) results in 1.

    Use MINUTE(A2) or perhaps MINUTE([@[Due Time]]) to extract the minute part of the time of day.

    [EDIT]....
    Quote Originally Posted by mariomp View Post
    BTW, I also tried "=MINUTE([@[Due Time]])" but that didn't work either and returned all zeros.
    Because the minute is indeed zero through row 71. =MINUTE(A72) returns 4 because A72 displays 19:04.

    I'm afraid I don't know how to work with table references.
    Last edited by joeu2004; 11-21-2017 at 12:12 AM. Reason: EDIT

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,594

    Re: Extract minute value

    B2:
    =MINUTE(Table1[[#This Row],[Due Time]])

    formatted as number not time
    Ben Van Johnson

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract minute value

    Or

    =TIME(,MINUTE([@[Due Time]]),)

    formatted mm:ss

    Returns time value of the minutes; eg. row 72 ... 19:04 04:00 = 0.00277777777777778 = 4/1440 of a day.
    Last edited by FlameRetired; 11-21-2017 at 01:07 AM.
    Dave

  6. #6
    Registered User
    Join Date
    12-27-2014
    Location
    Rio Rancho, NM
    MS-Off Ver
    Office 2010
    Posts
    43

    Re: Extract minute value

    Thanks all.
    I used this and it worked like a charm: =(TIME(,MINUTE([@[Due Time]]),))*1440

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract minute value

    Good deal. Thank you for the feedback and marking this thread Solved.

  8. #8
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Extract minute value

    Quote Originally Posted by mariomp View Post
    I used this and it worked like a charm: =(TIME(,MINUTE([@[Due Time]]),))*1440
    I cannot imagine why that would work, but not simply =MINUTE([@[Due Time]]). They should return the same value [1].

    For my edification, can someone else confirm that MINUTE([@[Due Time]]) does not work(!)? FlameRetired?

    (Recall that I cannot or do not how to use table object references. Sigh.)


    -----
    [1] Actually, TIME(...)*1440 is at risk of returning a non-integer. It should be rounded explicitly. But I confirmed that TIME(...)*1440 does indeed return integers for all minutes 1 through 59, when used in this manner.
    Last edited by joeu2004; 11-22-2017 at 12:10 PM. Reason: minor

  9. #9
    Registered User
    Join Date
    12-27-2014
    Location
    Rio Rancho, NM
    MS-Off Ver
    Office 2010
    Posts
    43

    Re: Extract minute value

    Quote Originally Posted by joeu2004 View Post
    I cannot imagine why that would work, but not simply =MINUTE([@[Due Time]]). They should return the same value [1].

    For my edification, can someone else confirm that MINUTE([@[Due Time]]) does not work(!)? FlameRetired?

    (Recall that I cannot or do not how to use table object references. Sigh.)


    -----
    [1] Actually, TIME(...)*1440 is at risk of returning a non-integer. It should be rounded explicitly. But I confirmed that TIME(...)*1440 does indeed return integers for all minutes 1 through 59, when used in this manner.
    I included the test file in my first post. Did you make it work without using the fractional multiplier (1440)?

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract minute value

    @ joeu2004

    I cannot imagine why that would work, but not simply =MINUTE([@[Due Time]]). They should return the same value [1].
    That returns an integer. In the case of row 72 (19:04) it returns a 4 (verify by F9 function key).

    Due to time formatting Excel "sees" 1/4/1900 12:00 AM and displays the time only ... 12:00 AM ... or 00:00.

    BTW the *1440 part mystified me. That returns an integer as well with the same results. I was trying to return the minutes (fractional part of a day ... 4/1440) time formatted. It's a different value.
    Last edited by FlameRetired; 11-22-2017 at 03:58 PM.

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract minute value

    @ mariomp

    There seems to be some confusion regarding how Excel deals with dates and times and formatting.

    If you aren't aware of it dates are integers. Days are numbered starting at 1 (1/1/1900). Today 11/22/2017 is day 43061. The formatting is for human eyes.

    Time however is a decimal "fraction" of a day. With 1440 minutes in a day 4 minutes = 4/1440 or about 0.00277777777777778. Once again the formatting is for human eyes. Excel "sees" that decimal.

    If you read my previous post to joeu2004 (#10) it may help answer.

    A lot depends upon how you wish to use the results of the formula. Do you want minutes as integers or as fractions of a day that they are?
    Last edited by FlameRetired; 11-22-2017 at 04:10 PM.

  12. #12
    Registered User
    Join Date
    12-27-2014
    Location
    Rio Rancho, NM
    MS-Off Ver
    Office 2010
    Posts
    43

    Re: Extract minute value

    Quote Originally Posted by FlameRetired View Post
    @ mariomp

    There seems to be some confusion regarding how Excel deals with dates and times and formatting.

    If you aren't aware of it dates are integers. Days are numbered starting at 1 (1/1/1900). Today 11/22/2017 is day 43061. The formatting is for human eyes.

    Time however is a decimal "fraction" of a day. With 1440 minutes in a day 4 minutes = 4/1440 or about 0.00277777777777778. Once again the formatting is for human eyes. Excel "sees" that decimal.

    If you read my previous post to joeu2004 (#10) it may help answer.

    A lot depends upon how you wish to use the results of the formula. Do you want minutes as integers or as fractions of a day that they are?
    Thanks for additional info.
    As stated in post #6, I got it working and working well.
    I marked the thread as solved.
    Joe had some questions afterwards, and I was tying to be helpful.

  13. #13
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Extract minute value

    Quote Originally Posted by mariomp View Post
    I used this and it worked like a charm: =(TIME(,MINUTE([@[Due Time]]),))*1440
    Quote Originally Posted by joeu2004 View Post
    I cannot imagine why that would work, but not simply =MINUTE([@[Due Time]]). They should return the same value
    Quote Originally Posted by mariomp View Post
    Did you make it work without using the fractional multiplier (1440)?
    You don't seem to understand.

    If =TIME(0,MINUTE([@[Due Time]]),0)*1440 works for you, so should simply =MINUTE([@[Due Time]]). Both should return the integer 4 when the time is 19:04, for example.

    When I tried the latter the first time, I got an inexplicable syntax errors. But that is simply because I do not know how to work with table object references.

    When I tried it again, replacing your formula in column B, both formulas do indeed work if I also change the cell format.

    That is, initially Excel displays 00:00 for both formulas. That is not "all zeros"; it is simply 00:00 time of day.

    When I format as General, I do indeed see the integer 4.

    So you should use simply =MINUTE([@[Due Time]]).

  14. #14
    Registered User
    Join Date
    12-27-2014
    Location
    Rio Rancho, NM
    MS-Off Ver
    Office 2010
    Posts
    43

    Re: Extract minute value

    Quote Originally Posted by joeu2004 View Post
    You don't seem to understand.

    If =TIME(0,MINUTE([@[Due Time]]),0)*1440 works for you, so should simply =MINUTE([@[Due Time]]). Both should return the integer 4 when the time is 19:04, for example.

    When I tried the latter the first time, I got an inexplicable syntax errors. But that is simply because I do not know how to work with table object references.

    When I tried it again, replacing your formula in column B, both formulas do indeed work if I also change the cell format.

    That is, initially Excel displays 00:00 for both formulas. That is not "all zeros"; it is simply 00:00 time of day.

    When I format as General, I do indeed see the integer 4.

    So you should use simply =MINUTE([@[Due Time]]).
    Got it, thanks. That simplifies things, and I'm always about KISS

+ 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. Formula to just extract Hour and Minute
    By Shellybelly in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-03-2015, 02:42 PM
  2. [SOLVED] Record on/off time for minute by minute data set
    By bdenzer in forum Excel General
    Replies: 5
    Last Post: 07-30-2015, 07:41 PM
  3. [SOLVED] Macro that runs every minute when System Clock changes minute?
    By naira in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-18-2013, 04:11 PM
  4. Replies: 2
    Last Post: 09-06-2013, 03:15 PM
  5. extract call workload in 15 minute increments
    By bradja in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-17-2013, 06:39 AM
  6. Correspond Dates to Minute by Minute Data
    By chubby127 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-22-2013, 05:50 AM
  7. rolling minute data into 30 minute averages
    By grc1980 in forum Excel General
    Replies: 0
    Last Post: 08-30-2006, 03:58 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