+ Reply to Thread
Results 1 to 4 of 4

Comparing 2 different time formats?

  1. #1
    Registered User
    Join Date
    10-11-2011
    Location
    texas
    MS-Off Ver
    Excel 2007
    Posts
    6

    Comparing 2 different time formats?

    Hi I am having trouble comparing 2 columns each containing a time value.
    The 1st column contains cells looking like this
    A6: 9/1/2011 8:47:07 AM

    the other column will have cells that look like this
    D6: 847

    I am working in VBA so would prefer to do this comparision in there but if it is easier to massage the cells prior to running my subroutine I will. I have taken cell A6 and split it into 2 cells which will look like
    A6: 9/1/2011 B6: 8:47

    Now I am unable to find a way to compare B6 to D6 having tried a few different ideas via cell formatting or converting values to "general" or numeric or pulling the data apart with text/left/right, etc. Also another idea that doesnt work is
    B6 =Hour(A6)&MINUTE(A6) -> the result is 80

    I am not sure it is relevant but the A6 field is formatted under Format Cells as "Time 13:30". The seconds are not needed.

    Any help or ideas are appreciated.
    Rob
    Last edited by mushin2003; 10-12-2011 at 10:16 AM.

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Comparing 2 different time formats?

    Try this

    =HOUR(MOD(A6,1))*100+MINUTE(MOD(A6,1))=D6

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Comparing 2 different time formats?

    PHP Code: 
    =text(int(d6/100) & ":" mod(d6;100),"hh:mm")=text(A6,"hh:mm"
    Last edited by snb; 10-12-2011 at 09:15 AM.



  4. #4
    Registered User
    Join Date
    10-11-2011
    Location
    texas
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Comparing 2 different time formats?

    Thank you for your replies! both Bob and Snb's responses work

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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