+ Reply to Thread
Results 1 to 9 of 9

Using MIN and MAX Function to find times

  1. #1
    Registered User
    Join Date
    03-19-2010
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2003
    Posts
    10

    Question Using MIN and MAX Function to find times

    Hi everyone:

    I am trying to find the minimum and maximum start and end times from a column of dates and times. I've attached a sample Excel document.

    Originally, I tried to use the MIN function for the minimum start time.
    Instead of using 3/8/10 11:55 AM as the minimum start time (Cell B4),
    I want to use 1:25 AM instead (Cell B2).

    The same goes for the MAX function for the maximum start time.
    Instead of using 3/18/2010 1:25:26 AM as the maximum start time (Cell B2),
    I want to use 4:15 PM instead (Cell B3)

    Using tips from previous replies to my post, I thought I could extract the times (Columns E and F) and use the MIN & MAX functions. Instead, Excel is showing 12:00:00 AM in all of the summary fields (F7, F8, F9, and F10).

    Thanks in advance for your help (again)!
    Attached Files Attached Files
    Last edited by endora75; 03-23-2010 at 03:49 PM. Reason: Problem solved!

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Using MIN and MAX Function to find times

    Hi,

    Not sure to fully understand ...
    But if your text function formats your times as needed, you can have in cell F7

    =TEXT(C7,"hh:mm am/pm")
    HTH

  3. #3
    Registered User
    Join Date
    03-19-2010
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Using MIN and MAX Function to find times

    Hello JR:

    Thank you for your reply. If you look at Cells F7, F8, F9 & F10 in the Excel attachment, I am trying to use the MIN and MAX functions to find the minimum and maximum start / end times. For some reason, all of the cells are displaying 12:00:00 AM instead of the correct time.

  4. #4
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Using MIN and MAX Function to find times

    see attached ...
    Is it fine with you ...?

    HTH
    Attached Files Attached Files

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Using MIN and MAX Function to find times

    It appears that you want to find the minimum and maximum times regardless of which day they occur.

    To find the min/max, you have to truncate the date/time to just the time. In Excel, date/time is stored as a real number of days, where the part after the decimal point is the fraction of a day. If you drop the part to the left of the decimal point you are left with just the time.

    See attached for a solution, which does not need any helper columns. In the MIN/MAX fields I have used an array formula to calculate the time portion, then find the min or max.

    Please let me know if you have questions.
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  6. #6
    Registered User
    Join Date
    03-19-2010
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Using MIN and MAX Function to find times

    6StringJazzer:

    This is exactly what I am trying to accomplish. Unfortunately, when I corrected Cell C9 in the sample worksheet, I received a #VALUE error. When I try to implement your solution in my workbook, it's also giving me a #VALUE error.

    I've attached the sample again with my attempted correction. Any more advice that you can provide would be greatly appreciated!
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Using MIN and MAX Function to find times

    Hi Peg,

    See attached ...

    HTH
    Attached Files Attached Files

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Using MIN and MAX Function to find times

    JeanRage's attachment has a good explanation, which I'll repeat and expand here.

    I am using an array formula (search Excel help for "array formula"). The array formula is a powerful feature in Excel that allows a limited type of iteration for all cells in a given range. In this case, we need to know the minimum time. The formula to look at a date/time in B2 and return time is:

    =$B$2-INT($B$2)

    We need to do the same thing for multiple cells and then find the min. To do this, an array formula will create an array of values that is the result of this calculation, then we apply the function to the entire array. To start along this path we create the formula:

    =MIN($B$2:B$4-INT($B$2:$B$4))

    For Excel to interpret this as an array formula, you must enter the formula by pressing CTRL-SHIFT-ENTER. (If the formula already exists, you must press F2 to edit then press CTRL-SHIFT-ENTER.) Then you will see

    {=MIN($B$2:B$4-INT($B$2:$B$4))}

    The braces are added by Excel when you enter an array formula; you cannot type them in yourself.

  9. #9
    Registered User
    Join Date
    03-19-2010
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2003
    Posts
    10

    Thumbs up Re: Using MIN and MAX Function to find times

    6StringJazzer & JR:

    Many thanks to you both ... I figured out why I could not simply copy & paste the formulas before I opened up your (JR) example.

    6StringJazzer's formula used arrays. I needed to modify the formula & then do CTRL + SHIFT + ENTER. Glad to have learned something new.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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