+ Reply to Thread
Results 1 to 5 of 5

Merge date and time column to compare with a single datetime column

Hybrid View

  1. #1
    Registered User
    Join Date
    04-17-2020
    Location
    Newcastle
    MS-Off Ver
    office 365
    Posts
    66

    Merge date and time column to compare with a single datetime column

    Hi Team,

    I have 2 date time values i need to compare to find a match.

    The first is split into separate date (column 1) and time (column 2). The second is a combined date and time in a single column.

    My thoughts were i need to merge the 2 columns into 1 and then compare it to the datetime column. I did that with:

    =CONCATENATE(TEXT(A2,"dd/mm/yyyy")&" "&TEXT(B2,"hh:mm:ss"))

    The values look the same format now in the 2 columns i have to compare but i'm not able to match them. I thought maybe it was because my combined column is a formula but even if i copy and paste it as a value and make sure the format cell option on both is the same custom format of "dd/mm/yyyy hh:mm:ss" it still doesnt work.
    Attached Files Attached Files

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

    Re: Merge date and time column to compare with a single datetime column

    Try this instead:

    =VALUE(CONCATENATE(TEXT(A2,"dd/mm/yyyy")&" "&TEXT(B2,"hh:mm:ss")))

    You were trying to compare text with a number.

    This will work just as well:

    =A2+B2
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    04-17-2020
    Location
    Newcastle
    MS-Off Ver
    office 365
    Posts
    66

    Re: Merge date and time column to compare with a single datetime column

    Thanks Ali, that was a silly oversight on my part

    With regards to the format which you can set on a cell/column (right click format cells>custom then your format mask ie. dd/mm/yyyy hh:mm:ss) is that basically just the way its viewed and it doesnt actually change the underlying data or data type?

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

    Re: Merge date and time column to compare with a single datetime column

    Yes. The underlying data type is a five-digit serial number for the date and decimal places for the time. 1 is 24 hours, and fractions of 1 are times.

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

  5. #5
    Registered User
    Join Date
    04-17-2020
    Location
    Newcastle
    MS-Off Ver
    office 365
    Posts
    66

    Re: Merge date and time column to compare with a single datetime column

    thanks Ali - done!

+ 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. Replies: 2
    Last Post: 03-24-2016, 11:49 PM
  2. Merge specific column data from multiple sheets in single column of new workbook.
    By kadam203 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-14-2016, 01:58 AM
  3. Merge date and time in one column
    By Krista1984 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 07-14-2014, 10:59 AM
  4. Merge date and time in one column
    By Krista1984 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 07-11-2014, 08:59 PM
  5. [SOLVED] Date function that compare 2 date in single column and return value
    By alimamak in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-20-2012, 06:45 AM
  6. Replies: 0
    Last Post: 07-27-2010, 03:08 PM
  7. Based on a Column datetime value auto calculate and populate a datetime range
    By rajashanmuga in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-22-2010, 04:10 PM

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