+ Reply to Thread
Results 1 to 11 of 11

Calculate number of days between two dates that are formatted like 6/30/2021 16:05

  1. #1
    Registered User
    Join Date
    08-29-2022
    Location
    Edmonton, Alberta
    MS-Off Ver
    Microsoft Office Professional Plus 2021
    Posts
    5

    Question Calculate number of days between two dates that are formatted like 6/30/2021 16:05

    Hello. I copied dates (formatted like 6/30/2021 16:05) from PointClickCare software and pasted them into an Excel file. When I try to substract two of the dates in Excel, I get a "#VALUE!" error.

    Example: Cell B2 has 6/30/2021 16:05
    Cell B3 has 5/5/2021 16:30
    Cell C2 has =B2-B3

    Is there a way for me to calculate the number of days between the two dates?

    Note: It's okay if the hours and minutes (e.g. 16:05) get removed from the cells. It's also okay if the date format gets changed.

    Thank you!

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,777

    Re: Calculate number of days between two dates that are formatted like 6/30/2021 16:05

    Without seeing a sample, you could try Text to Columns on the Data ribbon to convert them:

    1. Select a column containing 'dates'.
    2. Data ribbon | Text to Columns.
    3. Click Next > Next > choose DMY > Finish.

    If your locale uses MDY, then choose MDY at 3.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    08-29-2022
    Location
    Edmonton, Alberta
    MS-Off Ver
    Microsoft Office Professional Plus 2021
    Posts
    5

    Re: Calculate number of days between two dates that are formatted like 6/30/2021 16:05

    Thank you for your help AliGW. I followed your above steps, except that I needed to choose "space" in Step 2 and "Date: MDY" in Step 3 of the "Convert Text to Columns Wizard". This process put the month, day, and year data into a separate column from the hours and minutes.

    This method changed my above example as follows:
    Cell B2 now has 2021-06-30
    Cell B3 now has 2021-05-05
    Column C has all of the hours and minutes in it (e.g. 16:05).
    Cell D2 has =B2-B3 = 56 (days). This is correct.

    Do you know if there is a faster way to get the "dates" (e.g. 6/30/2021 16:05) in my original column B into a proper date format so that I can do calculations with them? For example, is there a formula that I could use in column A to automatically convert column B "dates" into a proper date format?

    Thank you very much!

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,777

    Re: Calculate number of days between two dates that are formatted like 6/30/2021 16:05

    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.

  5. #5
    Registered User
    Join Date
    08-29-2022
    Location
    Edmonton, Alberta
    MS-Off Ver
    Microsoft Office Professional Plus 2021
    Posts
    5

    Re: Calculate number of days between two dates that are formatted like 6/30/2021 16:05

    Hello AliGW. Please click on the below Excel sample workbook. It has two sheets in it: "Original" and "Preferred method". Thank you.

    Sample.xlsx

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,552

    Re: Calculate number of days between two dates that are formatted like 6/30/2021 16:05

    On the Original sheet put the following into cell A2 and double click the fill handle to copy down: =DATEVALUE(LEFT(B2,SEARCH(" ",B2)-1))
    Note that this will display a number which is the way Excel stores dates (number of days since 1/1/1900)
    You can change the way cell A2 displays the date but that isn't necessary.
    In C2 and down use: =A2-A3
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,777

    Re: Calculate number of days between two dates that are formatted like 6/30/2021 16:05

    Please try this:

    =INT((B2+0))-INT((B3+0))

  8. #8
    Registered User
    Join Date
    08-29-2022
    Location
    Edmonton, Alberta
    MS-Off Ver
    Microsoft Office Professional Plus 2021
    Posts
    5

    Re: Calculate number of days between two dates that are formatted like 6/30/2021 16:05

    Hello JeteMc and AliGW. I tried each of your methods in separate copies of my above "Sample" Excel file (in the spreadsheet named "Original"). Each of the following formulas gave me a #VALUE! error:
    • =DATEVALUE(LEFT(B2,SEARCH(" ",B2)-1)) and =A2-A3 in one copy of my "Sample" Excel file.
    • =INT((B2+0))-INT((B3+0)) in another copy of my "Sample" Excel file.

  9. #9
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,057

    Re: Calculate number of days between two dates that are formatted like 6/30/2021 16:05

    A long formula to get the correct date:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-29-2022
    Location
    Edmonton, Alberta
    MS-Off Ver
    Microsoft Office Professional Plus 2021
    Posts
    5

    Re: Calculate number of days between two dates that are formatted like 6/30/2021 16:05

    Hi josephteh. Your formula worked well. Thank you!

    Thank you everyone for all of your help!

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,777

    Re: Calculate number of days between two dates that are formatted like 6/30/2021 16:05

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon (* Add Reputation) 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 all those who offered help.

+ 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. How to use Regexmatch to filter ranges of Times & Dates (ie, 2021-01-05 08:00 - 2021-01-06
    By rddt in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 9
    Last Post: 01-10-2021, 05:01 PM
  2. Replies: 1
    Last Post: 01-10-2021, 04:32 AM
  3. [SOLVED] Calculate Number of Days Between Dates
    By tomskelly89 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-17-2020, 03:34 AM
  4. [SOLVED] Calculate number of days between 2 dates
    By mikehk in forum Excel General
    Replies: 3
    Last Post: 09-04-2018, 07:11 PM
  5. Replies: 7
    Last Post: 12-27-2017, 09:57 AM
  6. Calculate number of days between 2 dates
    By DTYS in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-28-2017, 06:01 AM
  7. Calculate number of days between 2 dates & then assign a number based on the answer
    By MrHappyGoLucky12 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-27-2014, 09:20 PM

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