+ Reply to Thread
Results 1 to 7 of 7

Date conversion

Hybrid View

  1. #1
    Registered User
    Join Date
    10-09-2012
    Location
    timbuktu
    MS-Off Ver
    Excel 2003
    Posts
    3

    Date conversion

    I have date time in the following format in Excel

    say

    A1 = Aug 14 2012 11:44AM
    B1 = Aug 16 2012 3:19PM

    I need to do subtract the time and report it in minutes. How can I do it in Excel.

    I get #Value when I try =(B1-A1)*1440
    Thanks!

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

    Re: Date conversion

    Welcome to the Forum!

    subtract two datetimes to get minutes.xlsx

    This works for me. I am guessing that you have text in those cells rather than actual date/time values. That will cause a #VALUE error. See my attachment for the correct way to do this.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

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

    Re: Date conversion

    Quote Originally Posted by 6StringJazzer View Post
    I am guessing that you have text in those cells rather than actual date/time values. That will cause a #VALUE error. See my attachment for the correct way to do this.
    I don't think the problem lies there. As the two values are used in an arithmetic operation, the text is immediately coerced to values. It would be interesting to see the real sheet

  4. #4
    Registered User
    Join Date
    10-09-2012
    Location
    timbuktu
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Date conversion

    Hi

    I have attached the sample xlsx.

    Thanks
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Date conversion

    Try,

    =(SUBSTITUTE(TRIM(REPLACE(B1,LEN(B1)-1,0," "))," ",", ",2)-SUBSTITUTE(TRIM(REPLACE(A1,LEN(A1)-1,0," "))," ",", ",2))*1440
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  6. #6
    Registered User
    Join Date
    10-09-2012
    Location
    timbuktu
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Date conversion

    Thank you so much that worked!

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

    Re: Date conversion

    The data is presented in text form, and it's a date/time format that is not recognized and therefore not automatically coerced. The formula above solves your immediate problem (and maybe that's enough) but in general, date/time data should be entered as date/time data rather than text. The formula converts the existing data into date/time data by removing the leading space, adding a comma after the day number, and inserting a space before AM/PM. This method could be used to modify all your data. You would then have to reformat from General to a Custom format of "Mmm d, yyyy hh:mm AM/PM".

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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