+ Reply to Thread
Results 1 to 8 of 8

Date Calculation is giving wrong answer!

  1. #1
    Registered User
    Join Date
    02-20-2019
    Location
    England
    MS-Off Ver
    0365
    Posts
    9

    Date Calculation is giving wrong answer!

    this is driving me crazy, it should be simple (and probably is to someone who knows the answer).

    I'm trying to calculate lapsed time with two values and then format that result to something readable. For example
    My start date is 20/02/2019 16:48:11 (except it appears at 2019-02-20 16:48:11 in the sheet but formatted this way when I copied the value)
    My end date is 20/02/2019 16:54:05 (same format as my start date so it's not a mismatch I don't think)

    So I expect my lapse time to calculate as
    00 Months 00 Days 00 Hours 05 Minutes 54 Seconds (this is the readable format I used on the cells)

    Except it actually show
    01 Months 00 Days 00 Hours 05 Minutes 54 Seconds

    Where is getting the 1 month from in the result ??

    The underlying formula is =IF(M2="",NOW()-B2,M2-B2) - where M2 is the end date but used NOW() in case it was blank

    Please, someone, stop my hair turning grey! I've hunted for the answer but am just stumped.


    p.s Hello by the way, this is not actually my first post but I couldn't reset my password on my old account so created a new one.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Date Calculation is giving wrong answer!

    What was your old account name? An admin may be able to help.

    As you are not new, you will know we need to see the 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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    02-20-2019
    Location
    England
    MS-Off Ver
    0365
    Posts
    9

    Re: Date Calculation is giving wrong answer!

    don't remember having to post the workbook .. so pointer on how to do that

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Date Calculation is giving wrong answer!

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.

  5. #5
    Registered User
    Join Date
    02-20-2019
    Location
    England
    MS-Off Ver
    0365
    Posts
    9

    Re: Date Calculation is giving wrong answer!

    aha .. found it.

    Here is the workbook minus the identifiable information (which is not used in the calculation anyway)
    Attached Files Attached Files
    Last edited by simplyoooo; 02-20-2019 at 06:09 PM.

  6. #6
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Date Calculation is giving wrong answer!

    As you are subtracting dates, or more specifically the underlying sequential number that represents the date,the result will also be a sequential number that represents a date. So the 1 comes from the fact your formula result is, if you format the cell as per the others, the date '1900-01-00 00:05:54'. The 1 is for 'January' and is returned by the 'M' in the number format you have applied to the formula cell.

    Take a look here for how to accurately subtract dates and times to get the elapsed result you require. Although this page is for an office add-in, the raw formula you are looking for is under the heading "Formula 5. Display time difference as "XX days, XX hours, XX minutes and XX seconds"

  7. #7
    Registered User
    Join Date
    02-20-2019
    Location
    England
    MS-Off Ver
    0365
    Posts
    9

    Re: Date Calculation is giving wrong answer!

    That helps but only if I format the end result with Days, Hours, Minutes, and Seconds. I have some long lapse times of over a year but when I tried adding those to the format it still gave me 1 Month where the result should be 0 months.

    What am I doing wrong ? This seemed so simple when I started working on this 'quick' report hours ago
    Last edited by AliGW; 02-21-2019 at 03:42 AM.

  8. #8
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Date Calculation is giving wrong answer!

    You can use the DATEDIF function to get the Months.

    Please Login or Register  to view this content.
    If the formula is getting a bit lengthy I would suggest using some additional columns and splitting each part of the formula out. Then just join it all back together for your result.

+ 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. [SOLVED] splitting formula giving wrong answer in a particular for specific pack size description
    By JEAN1972 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-28-2018, 01:40 PM
  2. [SOLVED] If function giving me the wrong answer
    By lmcc007 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-25-2018, 08:08 AM
  3. [SOLVED] Formula is giving a 0 answer, why???
    By MRozell in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-01-2015, 10:10 AM
  4. [SOLVED] Dividing cell is giving wrong answer
    By jwlamb in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-30-2014, 08:15 PM
  5. right calculation wrong answer
    By allinfernandez in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-06-2012, 10:07 AM
  6. Vlookup giving wrong answer
    By toclare84 in forum Excel General
    Replies: 5
    Last Post: 08-26-2010, 08:53 AM
  7. addition calculation not giving correct answer
    By lnjr in forum Excel General
    Replies: 2
    Last Post: 02-22-2009, 05:49 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