+ Reply to Thread
Results 1 to 10 of 10

Extract and sum TIME OF DAY from column with date and time info

  1. #1
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Extract and sum TIME OF DAY from column with date and time info

    Hello,

    I have a column of data with time and date.

    I want to COUNT number of instances in each hour of the day, so I can see pattern of time of day from data.

    I think I need SUMPRODUCT but the time of day is part of a string with date also which is confusing me.

    In the GREEN cells on STATS is where I want to count instances occurring in each hour (and drag right)

    Also, on the attached STATS sheet I can time time from and time to for each hour, but is there a formula I can put in the yellow cells and drag along to add an hour, without me typing each?

    Please would someone steer me on this?

    (note - have used COUNTIF perfectly for tallying by month and year, just can't figure TOD)

    Thanks,

    Ian
    Attached Files Attached Files

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,443

    Re: Extract and sum TIME OF DAY from column with date and time info

    Hi,

    First, to add an hour to an existing time, add 1/24 as excel regards a day as 1.

    eg, C2=B2+1/24

    The data you have posted isn't a string, rather a number that represents a date and time, therefore to obtain the AM times,

    B4=SUMPRODUCT((HOUR(DATA!$A$2:$A$29874)=B1-1)*(1))

    and for the PM times,

    B9=SUMPRODUCT((HOUR(DATA!$A$2:$A$29874)=B6+11)*(1))
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,147

    Re: Extract and sum TIME OF DAY from column with date and time info

    In "Data"

    in B2

    =MOD(A2,1)

    copy down

    format as hh:mm

    in "Stats"

    In C2

    =B2+1/24

    in C3

    =B3+1/24

    Drag across

    In B4

    =COUNTIFS(DATA!$B:$B,">=" &STATS!B$2,DATA!$B:$B,"<=" &STATS!B$3)
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Extract and sum TIME OF DAY from column with date and time info

    Thanks both,

    @sweep - the adding an hour is perfect - thank you. The SUMPRODUCT - can it work on the times in rows 2 and 3 (so it looks for times between, including the times themselves). I also need it to work on column A of DATA as a whole, as I'll drop in a whole dataset into this sheet which is raw data I just want the STATS to update on.

    @JohnTopley - thanks also. I'm needing a solution that means me NOT tweaking the DATA tab at all - due to the note above. I've used column A on my example but in the actual data - there are columns before and after (the time/date is actually in column Z of a much bigger set of info).

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,147

    Re: Extract and sum TIME OF DAY from column with date and time info

    Put the time following the Date/Time: with 16K columns to use ....

  6. #6
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Extract and sum TIME OF DAY from column with date and time info

    ....and I don't want to do any changes or tweaks at all on the DATA tab, so that method won't work for me, I'm sorry. I may be able to have a second sheet pulling the data from the DATA tab to then add your time column, as a workaround. Let me try that now.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,147

    Re: Extract and sum TIME OF DAY from column with date and time info

    You only need add the formula once into DATA: how is DATA normally populated?

  8. #8
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Extract and sum TIME OF DAY from column with date and time info

    I get a data dump of over 50 columns, and drop the entire thing in - each time, there are more rows for most recent engagements.

    Other data pulls from this so changing it in any way is not an option. Just working on pulling data elsewhere to then modify time and implement your solution and test.

  9. #9
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Extract and sum TIME OF DAY from column with date and time info

    Interestingly - both solutions work BUT Johns solution returns 5 fewer records on the PM row - when the formula is populated over the whole data (attached).

    It's an acceptable margin for error and while both require some tweaking to work on the entire column on time/dates, I do now have what's needed for analysis.

    Thanks both.

    Ian
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Extract and sum TIME OF DAY from column with date and time info

    posted in wrong thread, sorry

+ 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. extract time from date/time for sorting
    By always Stumped in forum Excel General
    Replies: 3
    Last Post: 01-22-2015, 08:20 PM
  2. [SOLVED] Extract time from date and time text string
    By pattem2013 in forum Excel General
    Replies: 5
    Last Post: 09-07-2013, 03:20 AM
  3. How can I extract an undated time value from a date/time field?
    By NPB in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-06-2013, 08:47 AM
  4. [SOLVED] Extract a time from a cell with date and time stamp and then perform calculations
    By Marcos Aristotelous in forum Excel General
    Replies: 3
    Last Post: 10-31-2012, 04:36 AM
  5. Replies: 4
    Last Post: 12-02-2011, 02:41 PM
  6. Calculating Time matching info in Data Validation Column and Date
    By dbroderick in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-25-2010, 04:22 PM
  7. Replies: 4
    Last Post: 03-23-2010, 12:44 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