Results 1 to 11 of 11
  1. #1
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74

    Counting Number of Days (not records) in a Month

    Greetings-

    Attached is a "TripsDatabase" which includes a Table and Report. The report shows records for two dates in January, and both dates fall on a Wed.

    Instead of counting 194 Wed, I'd like to count only two Wed, which I have attempted in the header of the report, but to no avail.



    I would be grateful for any assistance or direction on this matter..

    Thank you,

    -Tommy

    p.s. on a different post of mine, I thought you had helped me in solving this, so forgive me if this request may seem redundant..
    Attached Files Attached Files

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Not perfectly sure what you are trying to accomplish. If you want to count the number of Saturdays for a given date range, that would require some fancy code. It might be easier and quicker for the app to process the request if you stored some date info in a separate table to support the calculation.

    To answer a previous complex date question I created a little program that will first populate a table with dates and relative (calculated) data, like day of week. So, when you start the program you must first supply a date you want your table to begin with and the number of days forward you would like the table to end.

    If you choose 1/1/2000 to begin and 3000 days, the program will populate the table with dates from 1/1/2000 to 3/18/2008. There will be 3000 records in the table that you can use as a reference to do further calculations. I believe a table like this could help you because you can create a query to retrieve a date range and count the number of Saturdays. All you would need to start is the table.

    The attached app was not built to answer your question but it may help to incorporate the populated table in your DB.
    Attached Files Attached Files

  3. #3
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    ItsMe - thanks for sharing your Weekday database. I am sure that some of the code will prove useful in the further development of my projects.

    -Tommy

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Let us know if you still have questions. I felt like I had been down a similar road before. An additional table seems appropriate to me.

  5. #5
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    I still need help with an expression/code/SQL for counting the actual number of Wed - only two on the report (1/8/2014 and 1/15/2014) instead of counting all records that have "wed" (194).

    -Tommy

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    My solution would be to incorporate a table that has a column to indicate what weekday a given date is. Otherwise, you will have to hold many variables in memory as you create a date param and then evaluate the param.

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Create this query:

    Code:
    SELECT TA_REPOSITORY.DATED
    FROM TA_REPOSITORY
    GROUP BY TA_REPOSITORY.DATED
    HAVING (((TA_REPOSITORY.DATED)=#1/15/2014# Or (TA_REPOSITORY.DATED)=#1/8/2014#));
    Save it as qry_DaysActive

    On your report in the place where you currently have 194 showing

    put

    =dcount("*", "qry_DaysActive")

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    One note before you do this though, that your criteria driving the qry_DaysActive has to be the same (in terms of date range) as your main query. So if your actual query is using dates on a form as it's criteria use the same form references for qry_DaysActive.

  9. #9
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    repeare - setting up the query and using DCount moved me in the right direction, ultimately solving my issue!

    Thanks so much.

    -Tommy

  10. #10
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    A word of caution, do not use domain functions (dsum, dcount, davg, etc) in a query that you are using to build a report. For instance the query driving your report is fine, don't try to add a domain function to that, it will needlessly slow your query down. Domain functions should be used sparingly.

  11. #11
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    repeare - Thanks for the information..

    -Tommy

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

Similar Threads

  1. Counting Days of the Week
    By losingmymind in forum Reports
    Replies: 10
    Last Post: 12-23-2013, 03:30 PM
  2. Replies: 3
    Last Post: 06-19-2012, 10:42 PM
  3. How Counting Active Days?
    By harapan in forum Queries
    Replies: 9
    Last Post: 04-02-2012, 10:19 PM
  4. counting days
    By d3pl0y3d in forum Access
    Replies: 13
    Last Post: 04-28-2011, 06:31 PM
  5. Replies: 4
    Last Post: 08-27-2009, 01:21 AM

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