+ Reply to Thread
Results 1 to 6 of 6

Why MOD function works in calculation for elapsed time between 2 days

  1. #1
    Spammer
    Join Date
    02-21-2018
    Location
    England
    MS-Off Ver
    Excel 2016(&2010,2007), Word 2016 (&2010,2010)
    Posts
    141

    Why MOD function works in calculation for elapsed time between 2 days

    Is it something with Excel or my math is bad?

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Why MOD function works in calculation for elapsed time between 2 days

    Can you elaborate?

    But if you are asking general question on why mod works on time. It's because Excel stores time as decimal (fraction), 1 hour being 1/24.
    So MOD(Datetime, 1) strips date portion from datetime and leaves you with time only.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Why MOD function works in calculation for elapsed time between 2 days

    You haven't given us anything to go off of here.

    What does your data look like, what are you looking to do with it?

    Consider uploading a small representative sample workbook along with the desired results (which you can enter manually) based on that sample data.

    To upload an Excel workbook, follow these steps:
    1) Click on "Go Advanced"
    2) Click on "Manage Attachments"
    3) Click on "Choose File"
    4) Choose your file and click on "Open"
    5) Click on "Upload"
    6) Click on "Close this window"

  4. #4
    Spammer
    Join Date
    02-21-2018
    Location
    England
    MS-Off Ver
    Excel 2016(&2010,2007), Word 2016 (&2010,2010)
    Posts
    141

    Re: Why MOD function works in calculation for elapsed time between 2 days

    =MOD((2:00 AM - 10:00 PM ),1).
    How is "[mod of(why modulus)] 2:00 AM - 10:00PM /1" different from "2:00 AM - 10:00 PM".

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Why MOD function works in calculation for elapsed time between 2 days

    It's because Time can't be displayed when it's in negative value.

    So 2:00 - 22:00 won't work.

    MOD function, interprets -0.83333 as 1 - 0.83333 (more accurately, see below).
    Approx. 0.166667.

    Which is 4/24 or 4 hours.

    Note: Excel's Mod is expressed as
    MOD(n,d)=n-d*INT(n/d)

    You can test by using negative decimal.
    =MOD(-0.4,1) returns 0.6
    =MOD(-0.4,3) returns 2.6

    EDIT:
    Key here is INT(n/d)
    INT always rounds down. So 1/2 = 0. But rounding down on negative -1/2 = -1 since 0 is "up" from -0.5

    Therefore, INT(-0.83333/1), becomes -1.
    Last edited by CK76; 07-26-2018 at 09:42 AM. Reason: See EDIT:

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Why MOD function works in calculation for elapsed time between 2 days


+ 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. elapsed time either same day or between days
    By longfisher in forum Excel General
    Replies: 3
    Last Post: 08-23-2009, 02:33 PM
  2. Calculating time elapsed in days and count days within same range
    By michellem410 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-19-2008, 01:13 PM
  3. [SOLVED] Please Help With Days Elapsed And Days Remaining Calculation
    By Scoooter in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-14-2006, 12:15 PM
  4. [SOLVED] Elapsed time in days
    By Steve M via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  5. [SOLVED] Elapsed time in days
    By Bernie Deitrick in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 09-06-2005, 02:05 PM
  6. [SOLVED] Elapsed time in days
    By Bernie Deitrick in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-06-2005, 06:05 AM
  7. Elapsed time in days
    By Steve M via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  8. [SOLVED] Elapsed time in days
    By Steve M via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-08-2005, 02:07 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