+ Reply to Thread
Results 1 to 3 of 3

date in text format to date format

  1. #1
    Registered User
    Join Date
    01-19-2019
    Location
    Färlöv, Sweden
    MS-Off Ver
    Office 2010
    Posts
    1

    date in text format to date format

    Hello!

    I would need help learning how to convert text to date, see below.
    I get the following text from IFTTT to an excel sheet.

    January 19, 2019 at 11:24PM

    How can I convert this to a date / time format?

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: date in text format to date format

    Hello my friend.

    Such a simple question.

    Excel has a couple of simple tools that normally do the conversion.

    But they don't work for your data.

    So you are going to have to build a formula to do it.

    Datevalue() will normally convert a date as text into a date that Excel understands. Unfortunately Excel only understands, 1, 01 or Jan not January.

    So we have to get your date into a format that Datevalue undertands ie 19/1/2019

    If A1 is: January 19, 2019 at 11:24PM

    Then: MID(A1,FIND(" ",A1)+1,2) = 19

    LEFT(A1,FIND(" ",A1)-1) = January

    So:
    MATCH( LEFT(A1,FIND(" ",A1)-1),{"January","February"," March","April","May","June","July","August","September","October","November","December"},0)
    Returns =1

    MID(A1,FIND(",",A1)+2,4) = 2019

    Put that all together with a couple of "/" then we get

    =MID(A1,FIND(" ",A1)+1,2)&"/"&MATCH( LEFT(A1,FIND(" ",A1)-1),{"January","February"," March","April","May","June","July","August","September","October","November","December"},0)&"/"& MID(A1,FIND(",",A1)+2,4)

    This returns 19/1/2019

    Put that into Datevalue returns = 43484 which is your date as Excel sees it.

    =Datevalue(MID(A1,FIND(" ",A1)+1,2)&"/"&MATCH( LEFT(A1,FIND(" ",A1)-1),{"January","February"," March","April","May","June","July","August","September","October","November","December"},0)&"/"& MID(A1,FIND(",",A1)+2,4))

    '********************************************************************************************************************

    With regards to the time.

    RIGHT(A1,7) = 11:24PM

    So LEFT(RIGHT(A1,7),5) = 11:24

    Using Timevalue(LEFT(RIGHT(A1,7),5)) returns 0.475 which is 11:24AM as Excel sees it.

    Obviously you need 11:24 PM so yo need to add 0.5 which is 12/24 ie 12 hours

    +IF(RIGHT(A1,2)="PM",0.5,0)

    So: Timevalue(LEFT(RIGHT(A1,7),5))+IF(RIGHT(A1,2)="PM",0.5,0) = 0.975 which is 23:24 as Excel sees it.

    '************************************************************************************************************************

    So you formula is:

    =DATEVALUE(MID(A1,FIND(" ",A1)+1,2)&"/"&MATCH( LEFT(A1,FIND(" ",A1)-1),{"January","February"," March","April","May","June","July","August","September","October","November","December"},0)&"/"& MID(A1,FIND(",",A1)+2,4))+TIMEVALUE(LEFT(RIGHT(A1,7),5))+IF(RIGHT(A1,2)="PM",0.5,0)

    Which returns: 43484.975. There you are all done.

    Sorry. You are saying "But That Does Not Look Like A Date!!!!"

    Ok so you now need to format your cell so Excel knows to Display your number as Date and Time.

    So Right Click on your cell

    Select Format Cell
    Select Custom

    And paste this where it says Type: dd/mm/yyyy hh:mm then click on Ok.

    Phewwwwwwww.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: date in text format to date format

    A slightly shorter version...
    Assuming this text is in K12...
    Date...
    =DATEVALUE(LEFT(K12,FIND(" at",K12)-1))
    Time...
    =TIMEVALUE(SUBSTITUTE(SUBSTITUTE(RIGHT(K12,7),"PM"," PM"),"AM"," AM"))

    Then just add them together...
    =DATEVALUE(LEFT(K12,FIND(" at",K12)-1))+TIMEVALUE(SUBSTITUTE(SUBSTITUTE(RIGHT(K12,7),"PM"," PM"),"AM"," AM"))

    Then format as above
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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] Dates in Text and Date format, need help converting all to date format...
    By Branbran10 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-14-2016, 12:21 PM
  2. [SOLVED] Convety Text date format to a (numbered) date format
    By namluke in forum Excel General
    Replies: 1
    Last Post: 08-20-2014, 05:58 AM
  3. Excel:How change the textbox format from text to date format?
    By inpetto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-10-2013, 08:23 AM
  4. Convert date and time in serial number format to text format
    By nda13112 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-11-2013, 02:45 PM
  5. Replies: 5
    Last Post: 02-08-2013, 11:06 AM
  6. Cannot convert date (which is in text format) to date in numeric format
    By geniuspro in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-19-2012, 09:21 AM
  7. Replies: 2
    Last Post: 10-02-2010, 04:41 AM

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