Results 1 to 4 of 4
  1. #1
    racters is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2025
    Posts
    1

    Trying to count number of records by hour.

    Hello,

    I'm trying to count the number of records for each hour of the day.

    Ideally, I would like to bring in new data each day and be able to count the records. There is a field in the records that has date and time.



    Is it possible to code the query to pull this data for today's date so that I don't have to change the date every day?

    So far I think I need to add a total and use the criteria field to filter between the date and timestamps that I want to count.



    The data in the field looks like this

    TransmissionDate
    8/19/25 16:00
    8/19/25 16:00
    8/19/25 15:13
    8/19/25 15:13
    8/19/25 15:13
    8/19/25 15:13
    8/19/25 15:13
    8/19/25 15:13
    8/19/25 15:13
    8/19/25 15:13
    8/19/25 15:05
    8/19/25 15:05
    8/19/25 14:20
    8/19/25 14:20
    8/19/25 14:20
    8/19/25 14:20
    8/19/25 14:20
    8/19/25 14:20
    8/19/25 14:20
    8/19/25 13:40
    8/19/25 12:40
    8/19/25 12:39
    8/19/25 12:39
    8/19/25 12:39
    8/19/25 12:39
    8/19/25 12:39
    8/19/25 12:39
    8/19/25 12:39
    8/19/25 12:39
    8/19/25 12:39
    8/19/25 12:39
    8/19/25 12:39
    8/19/25 12:39
    8/19/25 12:12
    8/19/25 12:06
    8/19/25 11:40
    8/19/25 11:40
    8/19/25 11:40
    8/19/25 11:40
    8/19/25 11:38
    8/19/25 0:21

    I've added a total field and set it to count.

    My query design criteria so far is

    >=#8/19/2025# And <=#8/19/2025 1:00:00 AM#

    Can I use some kind of variable to selects today's date and still have a range of hours?


    I do apologize for the complete lack of knowledge on my end.

  2. #2
    Join Date
    Apr 2017
    Posts
    1,793
    Try
    Code:
    ... WHERE Int(TransmissionDate) = Date

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,575
    Just group by date to get the number per day.
    Group by date() and Hour() to get per hour

    This should get you started
    Code:
    SELECT DateValue([F1]) AS Expr1, Count(Hour([F1])) AS Expr2, Hour([F1]) AS Expr3
    FROM Times
    GROUP BY DateValue([F1]), Hour([F1])
    HAVING DateValue([F1]) = Date() ;
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    jojowhite's Avatar
    jojowhite is online now Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    444
    For Today's Count only:
    Code:
    SELECT Count(TransmissionDate) AS CountOfTransmissionDate
    FROM YourTableHere 
    HAVING (((DateValue([TransmissionDate]))=Date()));
    For Each day:
    Code:
    SELECT DateValue([TransmissionDate]) AS [Date], Count(TransmissionDate) AS CountOfTransmissionDate
    FROM YourTableHere 
    GROUP BY DateValue([TransmissionDate]);

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 07-25-2014, 09:25 AM
  2. Replies: 1
    Last Post: 01-31-2014, 11:03 PM
  3. Replies: 1
    Last Post: 10-20-2013, 10:04 AM
  4. Trying to find hour that has most attempts
    By pdpeterson87 in forum Queries
    Replies: 5
    Last Post: 10-08-2013, 03:52 PM
  5. Replies: 2
    Last Post: 03-02-2011, 01:43 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums