+ Reply to Thread
Results 1 to 7 of 7

Calculate Date Difference in terms of Hours

Hybrid View

  1. #1
    Forum Contributor wedzmer's Avatar
    Join Date
    06-13-2014
    Location
    Philippines
    MS-Off Ver
    2016
    Posts
    422

    Calculate Date Difference in terms of Hours

    I'm trying to help my brother who had this MS Excel assignment and I can't seem to get the right formula/logical argument for the conditions set in the problem.

    The Problem is stated as:

    "A car rental service posted a promo online where every vehicle will be rented for only $5 per day with $2 per hour if renter exceeds the prescribed period. If Alex Cooper rented a car at 7:00 AM of September 30 and returned it by 7:00 PM the following day, how much will he pay?"

    I placed A1 as Date of Release, B1 as Date Returned, C1 as Duration, D1 as Excess Hours, E1 as total.
    I got the duration simply by subtracting A1 and B1, but the excess hours doesn't seem to work correctly.
    Last edited by wedzmer; 10-03-2021 at 03:25 AM. Reason: typo error

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,610

    Re: Calculate Date Difference in terms of Hours

    I got the duration simply by subtracting C1 and B1
    I suppose you men subtracting A1 from B1 ?
    Perhaps try
    Formula: copy to clipboard
    =MOD(C1,24)
    in D1

  3. #3
    Forum Contributor wedzmer's Avatar
    Join Date
    06-13-2014
    Location
    Philippines
    MS-Off Ver
    2016
    Posts
    422

    Re: Calculate Date Difference in terms of Hours

    this will only compute the duration but not the excess hours, sir
    Last edited by AliGW; 10-03-2021 at 03:34 AM. Reason: PLEASE don't quote unnecessarily!

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Calculate Date Difference in terms of Hours

    Quote Originally Posted by wedzmer View Post
    this will only compute the duration but not the excess hours, sir
    I think you might need to review the MOD function which gives the remainder of a division so MOD(66,24)=18 for example

  5. #5
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,141

    Re: Calculate Date Difference in terms of Hours

    if C1 is a plain number, then try this in D1:
    =(B1-A1)*24-C1
    note: this assumes that C1 is where you enter the duration that is hired.

    if not, then without the duration hired for (the 8 hours) you can not do the calculation because who is to say how long it was hired for
    Last edited by janmorris; 10-03-2021 at 03:40 AM.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,565

    Re: Calculate Date Difference in terms of Hours

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  7. #7
    Valued Forum Contributor
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (24 H2) 64 Bit
    Posts
    1,185

    Re: Calculate Date Difference in terms of Hours

    Using Pepe Le Mokko's approach, I guess excess hours is;

    =MOD(C1*24,24)

+ 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. Calculate Shift Hours (Date/Time difference in an interval)
    By seanpark22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-28-2020, 04:39 PM
  2. Replies: 2
    Last Post: 08-07-2017, 06:25 PM
  3. Replies: 2
    Last Post: 08-06-2017, 08:54 PM
  4. Replies: 1
    Last Post: 09-13-2012, 05:50 AM
  5. Replies: 0
    Last Post: 09-13-2012, 05:28 AM
  6. Replies: 3
    Last Post: 12-23-2010, 04:46 PM
  7. [SOLVED] calculate difference in time to hours
    By Chris in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-18-2005, 03:06 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