+ Reply to Thread
Results 1 to 11 of 11

Convert date(text) to a number

  1. #1
    Registered User
    Join Date
    07-16-2012
    Location
    Antwerp, belgium
    MS-Off Ver
    Excel 2010
    Posts
    23

    Convert date(text) to a number

    I've a date in this format: 7/31/2012 12:00:00 AM (=31 July 2012 00:00:00)

    Now i need to convert it to a number so i can count with it.
    I tried datevalue and stuff but i keep getting the error #VALUE

    Someone any advice?
    Last edited by Jen Cop; 08-02-2012 at 04:47 AM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Convert date(text) to a number

    Can you post a few more examples (or a sample workbook)? Then we can see what happens with a single-digit date (like 1st July) - is it 01 or just 1?

    Also, isn't 12:00:00 AM the same as 12 noon?

    Pete

  3. #3
    Registered User
    Join Date
    07-16-2012
    Location
    Antwerp, belgium
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Convert date(text) to a number

    if its the 1st July then the date is 7/1/2012 12:00:00 AM
    And yes 12:00:00 AM is noon, my bad

    The meaning of all this is that i need to calculate how much timediff there is between 2 dates: A1=(7/31/2012 12:00:00 AM) and A2=(7/31/2012 12:01:00 AM)
    and i can't do A2-A1 because the dates are seen as text not as a number.

  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Convert date(text) to a number

    hi Jen Cop, i would suggest you do a Text To Column. assuming your data is in Column A, select it & go to Data -> Text To Column -> Delimited -> Next -> Check Space -> Next -> Choose Date -> MDY -> Destination: B1 (if you do not want to replace column A) -> Finish

    now in cell E:
    =B1+C1

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  5. #5
    Registered User
    Join Date
    07-16-2012
    Location
    Antwerp, belgium
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Convert date(text) to a number

    ok now i can work with it. thanks

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Convert date(text) to a number

    @ Jen Cop

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  7. #7
    Registered User
    Join Date
    07-16-2012
    Location
    Antwerp, belgium
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Convert date(text) to a number

    Yea i forgot, i was at work then. Sorry

    ---------- Post added at 10:07 AM ---------- Previous post was at 09:04 AM ----------

    Ok I now face the following problem:
    Cell A1 = 7/31/2012 12:00:00 AM
    Text-To-Column:
    B1 = 31/7/2012 (=number)
    C1 = 12:00:00 (= number)
    D1 = AM

    But I'm stuck here with 12h day and not a 24h day.
    There is no diff between 12 noon and 12 midnight.
    12 noon = 31/7/2012 12:00:00
    12 midnight = 31/7/2012 12:00:00
    I don't think Text-To-Column is right solution then? :s

  8. #8
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Convert date(text) to a number

    i thought it'll work in your case because you mentioned it's actually 12pm. you can use this formula instead of B1+C1:
    =B1+TIMEVALUE(RIGHT(A1,11))

    otherwise, you can ignore the Text to Column & do this. it's too troublesome to do up, so i avoided it:
    =DATE(MID(A1,FIND("/",A1,FIND("/",A1)+1)+1,4),LEFT(A1,FIND("/",A1)-1),MID(A1,FIND("/",A1)+1,FIND("/",A1,FIND("/",A1)+1)-FIND("/",A1)-1))+TIMEVALUE(RIGHT(A1,11))

  9. #9
    Registered User
    Join Date
    07-16-2012
    Location
    Antwerp, belgium
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Convert date(text) to a number

    I used text-to-column abit diff, now i get this
    A1= 7/31/2012 12:00:00 AM
    B1 = 31/7/2012 (number)
    C1 = 12:00:00 AM (format as [h]:mm:ss and it gives this: 0:00:00)
    D1 = B1+C1 = 31/7/2012 0:00:00
    and my last line is 31/7/2012 23:59:00, so ill mark this as solved now.
    I hope it work now in my main file. Thanks all

    ps: bensinshiryo, the timevalue doesnt work and long function gives error with me. but thanks anyway.

  10. #10
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Convert date(text) to a number

    just share with you what i did anyway.

    and thanks for the rep by the way
    Attached Files Attached Files

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Convert date(text) to a number

    This is the formula I came up with yesterday while working on this:

    =DATE(MID(A1,SEARCH("/",A1,3)+1,4),LEFT(A1,SEARCH("/",A1)-1),SUBSTITUTE(MID(A1,SEARCH("/",A1)+1,2),"/",""))+VALUE(MID(A1,SEARCH(" ",A1)+1,8))+IF(LEFT(RIGHT(A1,2))="P",0.5)

    Text date in A1, this formula in B1.

    Hope this helps.

    Pete

+ 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