Query that groups by month

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • question
    New Member
    • Oct 2006
    • 3

    Query that groups by month

    In my database i have a count for each day, but i need to sum the total for each month and the total for the year on one report. THe months must be the columns so i have to use a cross tab query. Because the dates use month, day, year, when i query it will only group the days together, not the months. Is there a way to reformat the dates into month and year only and query off of that by each year? Thanks
  • PEB
    Recognized Expert Top Contributor
    • Aug 2006
    • 1418

    #2
    Yeah,

    The way is to use the functions

    Year([Yourdate])
    Datepart("m",[YourDate])
    Datepart("yyyy" ,[YourDate])

    in your query!

    Best regards!

    Comment

    • question
      New Member
      • Oct 2006
      • 3

      #3
      Is there a way to format Date Part so it displays the month names instead of the month by number? Thanks.

      Originally posted by PEB
      Yeah,

      The way is to use the functions

      Year([Yourdate])
      Datepart("m",[YourDate])
      Datepart("yyyy" ,[YourDate])

      in your query!

      Best regards!

      Comment

      • question
        New Member
        • Oct 2006
        • 3

        #4
        Nevermind, I formatted it and it separated the month by itself. Thanks

        Originally posted by question
        Is there a way to format Date Part so it displays the month names instead of the month by number? Thanks.

        Comment

        • sanniep
          New Member
          • Aug 2006
          • 48

          #5
          Originally posted by question
          Nevermind, I formatted it and it separated the month by itself. Thanks
          The Datepart function does not recognize monthnames, the function Format does; Format([YourDate];"mmmm")..

          Comment

          Working...