Results 1 to 7 of 7
  1. #1
    bigot is offline Advanced...ish
    Windows 7 32bit Access 2007
    Join Date
    Feb 2014
    Posts
    37

    Summary (Count) Of Multiple Date Fields By Month

    Hi All,



    What I have:
    A table with multiple Date/Time columns. Here's an example:





    What I would like:
    A month-by-month summary counting the number of entries in each of the three columns, like this:



    I'm indifferent as to what happens with the months zeros across all three fields (whether they show up in the report with zeros or are omitted altogether).




    Smaller Pieces:
    I am able to create such a summary for one column at a time:




    Not what I'm looking for:
    I can not figure out how to create a query that does this for all three columns. My best attempt was a disaster:








    Any help/insight would be greatly appreciated. I have attached the example file for your convenience: Database1.accdb

    Thank you.



    EDIT:To clarify, my issue isn't the format of the date. I know about the Month(...) function. My question is regarding how to count this data and split it into a month-by-month summary (see the picture above in the "What I would like:" section)
    Last edited by bigot; 02-13-2014 at 09:37 PM. Reason: Clarification

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    The month function returns an integer.

    untested
    Dim intMonth as integer

    intMonth= ("#1/1/2010#")

    debug.print intMonth

  3. #3
    bigot is offline Advanced...ish
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    37
    Quote Originally Posted by ItsMe View Post
    The month function returns an integer.
    I think you misunderstood the question. Whether using an integer or a year-month concatenated string is irrelevant. I don't know how to create a query that produces a result with the first column being the month (doesn't matter if int or string). The second column is the number of "BirthDate"s that occur in that month. The third column is the number of "OtherDate"s that occur in that month. and the Fourth column is the number of "DeathDate"s that occur in that month.


  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    OK........

  5. #5
    bigot is offline Advanced...ish
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    37



  6. #6
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Here ya go.

    qryBAD is the main query with the results you're looking for.

    I made a union query that takes your qryBirth, qryOther, and qryDeath queries and captured all of the possible months in them. Then I did a left join of the Union query and each of the date queries based on the month values of each table. Then added an nz() function on the counts to make sure nulls resulted in 0. Voila.

    Click image for larger version. 

Name:	qryBAD.jpg 
Views:	11 
Size:	23.1 KB 
ID:	15380
    Attached Files Attached Files

  7. #7
    bigot is offline Advanced...ish
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    37
    Quote Originally Posted by Xipooo View Post
    Here ya go.

    qryBAD is the main query with the results you're looking for.

    I made a union query that takes your qryBirth, qryOther, and qryDeath queries and captured all of the possible months in them. Then I did a left join of the Union query and each of the date queries based on the month values of each table. Then added an nz() function on the counts to make sure nulls resulted in 0. Voila.
    Perfect, this is exactly what I was looking to do!

    I had tried joining, but I did not think to create a query to list all of the possible months (oops).


    Thank you Xipooo.





    If a reply resolves your issue, please click on the Thread Tools and mark it as Solved!
    Also give some credit by Clicking on the Star in the lower left corner of their post!
    Done and done.

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

Similar Threads

  1. Replies: 1
    Last Post: 08-26-2013, 05:08 PM
  2. not count date fields if the same
    By Icky_Joe in forum Queries
    Replies: 2
    Last Post: 04-11-2012, 12:55 PM
  3. Multiple count of query fields
    By BLD21 in forum Queries
    Replies: 2
    Last Post: 05-23-2011, 01:09 PM
  4. Replies: 1
    Last Post: 02-25-2011, 06:11 PM
  5. Replies: 2
    Last Post: 08-25-2010, 01:42 PM

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