+ Reply to Thread
Results 1 to 12 of 12

How to compare date & time value against date only value

  1. #1
    Registered User
    Join Date
    08-24-2014
    Location
    Salt Lake City, UT
    MS-Off Ver
    Office Professional 2013
    Posts
    8

    How to compare date & time value against date only value

    I have two tables (sheets) that I am working with. One has only the date and the other has date and time in the same column. Here are examples:

    Date Count
    8/22/2014
    8/23/2014
    8/24/2014

    Date Data
    8/22/2014 20:05 1
    8/22/2014 21:12 1
    8/23/2014 12:15 2
    8/23/2014 14:45 2
    8/23/2014 16:23 2
    8/24/2014 13:23 3
    8/24/2014 15:20 3
    8/24/2014 18:43 3

    I need to count all of the entries for each day. If I use the following formula it returns a zero because the one sheet only uses date while the other includes time as well:
    Please Login or Register  to view this content.
    However, if I go to Sheet2, insert a new column and use the follow formula to only pull the date from the date/time cell
    Please Login or Register  to view this content.
    (I drag this down so that each row now has a value with only the date value in it), and compare against this new column, it works like a charm.

    However, my goal is to be able to not create this additional column and just add the INT formula into the COUNTIF formula. For example, if I try doing this:
    Please Login or Register  to view this content.
    I get a nondiscript formula error.

    Does anyone have any suggestions on how I can compare the date column to the date/time column without having to create a new column on sheet2 using the INT formula?

    Thanks in advance for your help!

    Jason P.
    Attached Files Attached Files
    Last edited by Jason P.; 08-24-2014 at 12:46 PM. Reason: I attached an example .xlsx file

  2. #2
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: How to compare date & time value against date only value

    Enter the formula with Ctrl + Shift + Enter instead of just enter.
    =COUNTIF(Sheet2!(INT(A:A),A2)
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  3. #3
    Registered User
    Join Date
    07-30-2011
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    83

    Re: How to compare date & time value against date only value

    See attached. I used sumproduct to get the array cookin'.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-24-2014
    Location
    Salt Lake City, UT
    MS-Off Ver
    Office Professional 2013
    Posts
    8

    Re: How to compare date & time value against date only value

    Quote Originally Posted by Jacc View Post
    Enter the formula with Ctrl + Shift + Enter instead of just enter.
    =COUNTIF(Sheet2!(INT(A:A),A2)
    Thank you for answering.

    I tried this but it still gives me a formula error.

  5. #5
    Registered User
    Join Date
    08-24-2014
    Location
    Salt Lake City, UT
    MS-Off Ver
    Office Professional 2013
    Posts
    8

    Re: How to compare date & time value against date only value

    Thanks for your answer. While this does work, the data file that I pull the data from is constantly adding records. Therefore, I would like to be able to just reference the column instead of setting the cell range.

    For example:
    Please Login or Register  to view this content.
    However, when I try this I get the following result: #VALUE!

    Thanks again for your help!

    Jason P.

  6. #6
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How to compare date & time value against date only value

    On sheet2 insert a helper column so that the dates and times are in column B and enter this in column A and copy down.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This will extract the date only.

    Then on sheet1 enter this in column B and copy down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  7. #7
    Registered User
    Join Date
    07-30-2011
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    83

    Re: How to compare date & time value against date only value

    I would just make the end point sufficiently large for your purposes. Say 7,000 or so?

  8. #8
    Registered User
    Join Date
    08-24-2014
    Location
    Salt Lake City, UT
    MS-Off Ver
    Office Professional 2013
    Posts
    8

    Re: How to compare date & time value against date only value

    Quote Originally Posted by newdoverman View Post
    On sheet2 insert a helper column so that the dates and times are in column B and enter this in column A and copy down.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This will extract the date only.

    Then on sheet1 enter this in column B and copy down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Hi Newdoverman,

    Thanks for your reply. I believe that I may have not made my desire clear enough in my initial post. My goal is to be able to set a formula on sheet 1 that does everything so I don't have to make "any" changes to sheet 2. Sheet 2 is meant to be raw data that I can simply upload a new version of sheet to and all of the formula's on sheet 1 will continue to work regardless of how many rows of data are in sheet 2.

    I hope this clears things up a little.

    Again, thanks everyone for your help!

    Jason P.

  9. #9
    Forum Expert boopathiraja's Avatar
    Join Date
    07-12-2013
    Location
    Coimbatore,TamilNadu, India
    MS-Off Ver
    Excel 2007, 2013, 2016, 365
    Posts
    1,455

    Re: How to compare date & time value against date only value

    You may try this

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Click just below left if it helps, Boo?ath?

  10. #10
    Registered User
    Join Date
    08-24-2014
    Location
    Salt Lake City, UT
    MS-Off Ver
    Office Professional 2013
    Posts
    8

    Re: How to compare date & time value against date only value

    Quote Originally Posted by Yogi52o View Post
    I would just make the end point sufficiently large for your purposes. Say 7,000 or so?
    That would fix it in the short term but eventually there could be a tremendous amount of records and so I would like to keep the processing time down when not needed, if possible.

  11. #11
    Registered User
    Join Date
    08-24-2014
    Location
    Salt Lake City, UT
    MS-Off Ver
    Office Professional 2013
    Posts
    8

    Re: How to compare date & time value against date only value

    Quote Originally Posted by boopathiraja View Post
    You may try this

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This worked perfectly! Thanks!

  12. #12
    Registered User
    Join Date
    07-30-2011
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    83

    Re: How to compare date & time value against date only value

    I believe the problem is in the header; it is definitively not a value that you can multiply and such. So maybe 7000 isn't sufficiently large -- what about 500000?

    Or as I mentioned, if you dispensed with the header, you could get away with the A:A syntax for the column.

+ 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] Compare date and time in two cells
    By sa02000 in forum Excel General
    Replies: 8
    Last Post: 03-25-2014, 01:50 PM
  2. Compare two date/time columns
    By sulbaran in forum Excel General
    Replies: 15
    Last Post: 12-12-2013, 03:54 PM
  3. Replies: 1
    Last Post: 07-01-2010, 11:32 AM
  4. Formula to compare and amend date and time
    By Saajan in forum Excel Formulas & Functions
    Replies: 22
    Last Post: 06-03-2010, 04:34 AM
  5. Date and time compare
    By knowledge_619 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-23-2005, 05:25 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