+ Reply to Thread
Results 1 to 14 of 14

Calculate value of date and time difference

  1. #1
    Registered User
    Join Date
    09-21-2015
    Location
    Gauteng, South Africa
    MS-Off Ver
    Office 2010
    Posts
    11

    Exclamation Calculate value of date and time difference

    HI,

    I have watched and executed all the guides and tips from all the VBA and you tube tutorials.
    Unfortunately, my formulas still don't work.

    I have 3 columns:
    Time start (A1), Time end (B1) and Difference of time (C1)
    My formulas are as follows:
    A2 2014/03/03 08:11:01 AM
    B2 2014/03/03 01:00:50 PM
    C2 =B2-A2 (format: custom/(h):mm:ss

    I have chosen every single formatting option for columns A and B but still get the error #VALUE in C2.

    PLEASE CAN YOU ASSIST!

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Calculate value of date and time difference

    pls attach sample excel file
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Registered User
    Join Date
    09-21-2015
    Location
    Gauteng, South Africa
    MS-Off Ver
    Office 2010
    Posts
    11

    Re: Calculate value of date and time difference

    Thank you.

    However, where is the link to attach the file - please?

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Calculate value of date and time difference

    Attach A File.jpg
    follow the image

  5. #5
    Registered User
    Join Date
    09-21-2015
    Location
    Gauteng, South Africa
    MS-Off Ver
    Office 2010
    Posts
    11

    Re: Calculate value of date and time difference

    Thank you.

    Please refer to attached.

    Kind regards,

  6. #6
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Calculate value of date and time difference

    =TEXT(DATEVALUE(G6)+TIMEVALUE(G6)-DATEVALUE(F6)-TIMEVALUE(F6),"[h]:mm:ss")
    Please Login or Register  to view this content.
    Try this and copy towards down

  7. #7
    Registered User
    Join Date
    09-21-2015
    Location
    Gauteng, South Africa
    MS-Off Ver
    Office 2010
    Posts
    11

    Re: Calculate value of date and time difference

    Hi,
    Unfortunately, its not working. What format does columns A and B need to be in? Text formatting?
    What about Column C (currently custom/(h):mm:ss?

  8. #8
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Calculate value of date and time difference

    see the attached file
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    09-21-2015
    Location
    Gauteng, South Africa
    MS-Off Ver
    Office 2010
    Posts
    11

    Re: Calculate value of date and time difference

    Thank you, when I open the file I can see the calculated time - however it is in protected view. The moment I select enable editing, it gives me the #VALUE errors again.

  10. #10
    Registered User
    Join Date
    09-21-2015
    Location
    Gauteng, South Africa
    MS-Off Ver
    Office 2010
    Posts
    11

    Re: Calculate value of date and time difference

    I have even tried the following, which seems to have worked for another user:

    1. Highlighted the date and time column;
    2. Selected Data in the menu across the top;
    3. Chose "text to columns" option;
    4. Clicked on "finish"
    5. Highlighted my time column and chose formatting as "mm:ss.00"
    6. In my time difference column I chose the formatting as "(h):mm:ss
    7. I also looked at my regional settings and ensured that I chose the English (UK) option.

    Nothing seems to work.

  11. #11
    Registered User
    Join Date
    05-28-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2019
    Posts
    12

    Re: Calculate value of date and time difference

    Hi Legal_Consult

    You have a space preceding the values of the from and to dates. Use a Trim formula to remove the spaces and then your simple deduction of end time - start time will work.

    Cheers

  12. #12
    Registered User
    Join Date
    09-21-2015
    Location
    Gauteng, South Africa
    MS-Off Ver
    Office 2010
    Posts
    11

    Re: Calculate value of date and time difference

    Thank you Marais, I will try it.

  13. #13
    Registered User
    Join Date
    09-21-2015
    Location
    Gauteng, South Africa
    MS-Off Ver
    Office 2010
    Posts
    11

    [RESOLVED] Re: Calculate value of date and time difference

    Thank you MaraisV and nflsales,

    I have now managed to get it right. My problem was the spaces before the dates.

    Regards,

  14. #14
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Calculate value of date and time difference

    You can convert your dates to real Excel dates by using the Text to Columns feature of Excel.
    1. Select the Start time column
    2. Click on Text to Columns
    3. Click next
    4. Click on each of the arrows separating the sections of the date and time and drag them off the display to get rid of them and click Next.
    5. Click on Date and select YMD and click Finish.

    Format the result as d/mm/yyy h:mm:ss AM/PM

    Repeat for the End Date and times.
    In H6 enter the following and fill down and format as h:mm:ss
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This formula will also calculate the time difference of the text date and times that you have:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    F
    G
    H
    5
    Transaction Start Time Transaction End Time Time Difference
    6
    03/03/2014 8:11:01 AM
    03/03/2014 1:00:50 PM
    4:49:49
    7
    03/03/2014 1:00:50 PM
    03/03/2014 2:12:59 PM
    1:12:09
    8
    03/03/2014 2:12:59 PM
    03/03/2014 5:14:11 PM
    3:01:12
    9
    03/03/2014 5:14:11 PM
    04/03/2014 8:01:13 AM
    14:47:02
    Last edited by newdoverman; 09-22-2015 at 11:10 AM.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

+ 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. Macro to calculate the time difference for each date
    By Praveenkumarcg01 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-01-2013, 10:20 AM
  2. Replies: 1
    Last Post: 09-13-2012, 05:50 AM
  3. Replies: 0
    Last Post: 09-13-2012, 05:28 AM
  4. Replies: 3
    Last Post: 03-02-2012, 08:18 PM
  5. Calculate Date with Time Difference
    By OceanBlue in forum Excel General
    Replies: 2
    Last Post: 08-30-2011, 06:27 PM
  6. Replies: 3
    Last Post: 12-23-2010, 04:46 PM
  7. Calculate Difference between two Date/Time
    By Buks in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-16-2009, 03:06 AM

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