+ Reply to Thread
Results 1 to 15 of 15

Date Extraction and then time calculation between two dates

  1. #1
    Registered User
    Join Date
    07-22-2017
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2016
    Posts
    9

    Unhappy Date Extraction and then time calculation between two dates

    Hi all,

    I have the following date format in one cell (examples):
    Dec 28 2017 11:01AM
    Jan 3 2018 2:25PM
    Mar 2 2017 12:12PM

    As you can see, they vary in text length so I can't use left, right or mid, at least I think I can't

    I need to extract the date and time from those cells. After I extract it, I then need to find the difference between the times to the second. In my example, the difference for example from Dec 28 2017 11:01AM to Jan 3 2018 2:25PM in seconds which I would then convert to days, hours, minutes and seconds. Please help.

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Date Extraction and then time calculation between two dates

    The times are being seen as Text (i.e. with the date in A1, =ISNUMBER(A1) returns FALSE)?

    If so,

    =SUBSTITUTE(SUBSTITUTE(A1," ",", ",2),RIGHT(A1,2)," "&RIGHT(A1,2))+0 will convert the text date and time to an actual date and time.

  3. #3
    Registered User
    Join Date
    07-22-2017
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2016
    Posts
    9

    Re: Date Extraction and then time calculation between two dates

    Thank you for the prompt response, so that worked for the first date, but not the second date, got a Value error. Could it be the text length?

  4. #4
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Date Extraction and then time calculation between two dates

    No, the length doesn't matter. It worked on all 3 for me.

    See attachment.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-22-2017
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2016
    Posts
    9

    Re: Date Extraction and then time calculation between two dates

    Oh no, then there is more to the problem then. I just looked closely at my data and there is extra spaces for the potential date and time fields. For example: Jan _3 2018 _2:25PM and those underscores are blanks. I hadn't seen them. So in your sheet, you are correct, the text length doesn't matter but on mine, since it has extra blanks spaces, it's breaking.

  6. #6
    Registered User
    Join Date
    07-22-2017
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2016
    Posts
    9

    Re: Date Extraction and then time calculation between two dates

    So the data is:
    Dec 28 2017 11:01AM
    Jan 3 2018 2:25PM
    Mar 2 2017 12:12PM

  7. #7
    Registered User
    Join Date
    07-22-2017
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2016
    Posts
    9

    Re: Date Extraction and then time calculation between two dates

    I just realized the forum is removing the extra space, in the data above but again it would be Jan _3 2018 _2:25PM but the underscores are blanks.

  8. #8
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Date Extraction and then time calculation between two dates

    Sometimes this forum trims excess spaces and combines them into one. That is probably why posts 1 and 6 are showing single spaces.

    So just to be clear you are saying that there are 2 spaces after the month, 1 space after the day, and 2 spaces after the year?

    In that case, try this:

    B1 =TRIM(SUBSTITUTE(SUBSTITUTE(A1," ",", ",3),RIGHT(A1,2)," "&RIGHT(A1,2)))+0

  9. #9
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Date Extraction and then time calculation between two dates

    Maybe try with Get&Transform
    Duration format: d.hh.mm.ss

    (IMHO, data should be better organized )

  10. #10
    Registered User
    Join Date
    07-22-2017
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2016
    Posts
    9

    Re: Date Extraction and then time calculation between two dates

    Quote Originally Posted by 63falcondude View Post
    Sometimes this forum trims excess spaces and combines them into one. That is probably why posts 1 and 6 are showing single spaces.

    So just to be clear you are saying that there are 2 spaces after the month, 1 space after the day, and 2 spaces after the year?

    In that case, try this:

    B1 =TRIM(SUBSTITUTE(SUBSTITUTE(A1," ",", ",3),RIGHT(A1,2)," "&RIGHT(A1,2)))+0
    I'm sorry that I haven't put it more clearly. So for example, if it's Jan 12 then there is only one space between Jan and 12. If it is Jan 2, then there is two spaces between Jan and 2 because they system my client uses I guess is leaving an extra space in case it was double digits. The same with time. So maybe this might help. Jan__2_12:20PM or Jan_12__2:20PM or Jan_12_12:20PM

  11. #11
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Date Extraction and then time calculation between two dates

    Okay, it will be best for you to upload an actual Excel workbook with a representative sample of your data in it. That way we don't keep playing ping pong until I guess right.

    To upload an Excel workbook, follow these steps:
    1) Click on "Go Advanced"
    2) Click on "Manage Attachments"
    3) Click on "Choose File"
    4) Choose your file and click on "Open"
    5) Click on "Upload"
    6) Click on "Close this window"

  12. #12
    Registered User
    Join Date
    07-22-2017
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2016
    Posts
    9
    Quote Originally Posted by 63falcondude View Post
    Okay, it will be best for you to upload an actual Excel workbook with a representative sample of your data in it. That way we don't keep playing ping pong until I guess right.

    To upload an Excel workbook, follow these steps:
    1) Click on "Go Advanced"
    2) Click on "Manage Attachments"
    3) Click on "Choose File"
    4) Choose your file and click on "Open"
    5) Click on "Upload"
    6) Click on "Close this window"
    Ok I attached
    Attached Files Attached Files

  13. #13
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Date Extraction and then time calculation between two dates

    Last edited by sandy666; 02-15-2018 at 05:51 PM.

  14. #14
    Registered User
    Join Date
    07-22-2017
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2016
    Posts
    9

    Re: Date Extraction and then time calculation between two dates

    Quote Originally Posted by sandy666 View Post
    I'll try again
    Hi Sandy, although the desired output so thank you, I need to run it on various reports and have it set up as a formula for daily data. I wouldn't even know where to begin with get and transform since I have zero experience with that

    Thank you for posting that though

  15. #15
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Date Extraction and then time calculation between two dates

    Based on the workbook in post #12, put this formula in C6:

    =SUBSTITUTE(SUBSTITUTE(TRIM(A6)," ",", ",2),RIGHT(A6,2)," "&RIGHT(A6,2))+0

    Drag it over to D6 and then down.

+ 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. Time Calculation between two dates with different times
    By prithi in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 10-11-2016, 04:57 AM
  2. Replies: 7
    Last Post: 06-07-2015, 10:13 AM
  3. Time Calculation (Spanning Dates and using Military Time)
    By HospitalOfficer in forum Excel General
    Replies: 5
    Last Post: 07-29-2014, 12:18 PM
  4. Time calculation between two dates
    By rajibmishra in forum Excel General
    Replies: 16
    Last Post: 06-25-2014, 03:53 AM
  5. Calculation of time difference between the Start date & time & End Date & time
    By Harry Jones in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-17-2012, 03:54 PM
  6. [SOLVED] Calculation of Time where the dates are different
    By Noor Rahmani in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-06-2012, 12:20 AM
  7. Complex calculation including extraction of month from date field
    By arbourp in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-01-2007, 04:08 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