need help counting specific dates in query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Darknight850
    New Member
    • May 2007
    • 32

    #1

    need help counting specific dates in query

    Hello all,

    I am having a rather simple problem that for some reason i can not get to work. i have a date field, and i want to simply count all of the current dates(as in today) in that field.

    What I have that is not working:

    Code:
    count([Date Field])=Date() as Date Field
    I know i am missing something, I think I read some were to sum it up, but I tried and that didn't work eather. If some one could help me that would be great.
  • damonreid
    Recognized Expert New Member
    • Jul 2007
    • 114

    #2
    I know you could build a query to filter for a particular date and run a report based on that query.

    In the footer make a text box with the following code.

    [code=vb]=Count([SomeFieldThatIs FilledInForAllR ecords])[/code]

    Comment

    • abolos
      New Member
      • Apr 2007
      • 65

      #3
      Originally posted by Darknight850
      Hello all,

      I am having a rather simple problem that for some reason i can not get to work. i have a date field, and i want to simply count all of the current dates(as in today) in that field.

      What I have that is not working:

      count([Date Field])=Date() as Date Field

      I know i am missing something, I think I read some were to sum it up, but I tried and that didn't work eather. If some one could help me that would be great.
      For counting use COUNT in the record source of the field. So in the Record Source of the field put:
      =COUNT([text0])

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        Again, you've left us very little contextual information to work with. However, as a general concept you can try :
        Code:
        SELECT ...
               Sum(IIf([Date Field]=Date(),1,0)) AS [TodayCount],
               ...
        FROM [YourTable]

        Comment

        • Darknight850
          New Member
          • May 2007
          • 32

          #5
          Originally posted by NeoPa
          Again, you've left us very little contextual information to work with. However, as a general concept you can try :
          Code:
          SELECT ...
                 Sum(IIf([Date Field]=Date(),1,0)) AS [TodayCount],
                 ...
          FROM [YourTable]
          Thank you very much that worked perfectly, I had tried a IIF statement like that befor but I had not done it in a while in the SQL and just did IF and didn't want to work. I am also sorry i do not provide so much data, i try just to provide enough to get the information threw, it is easier for me this way since i have to replace the real field names with fake ones.

          Thank you again

          Comment

          Working...