Results by Month

Results 1 to 2 of 2

Thread: Results by Month

  1. #1
    Join Date
    Dec 1969

    Default Results by Month

    Hello,<BR><BR>I have a table with a "DateCreated" (mm/dd/yyyy) field. I want to COUNT the number of records by month. How would I do this in SQL, and how would I output the results?<BR><BR>IE. &#124 Month &#124 New Users &#124<BR> &#124 January &#124 5 users &#124<BR> &#124 February &#124 0 users &#124<BR><BR>etc.<BR><BR>Can this be done in 1 SQL statement with no stored procedures?<BR><BR>Much Appreciated,<BR>David Loeppky

  2. #2
    Join Date
    Dec 1969

    Default RE: Results by Month

    select month(dateCreated),count(*)<BR> from t<BR> group by month(dateCreated)<BR> order by month(dateCreated)<BR><BR>will get result for all months where there exists records, i.e. it can not return <BR><BR>February &#124 0 users <BR><BR>To get that as well, in a single query, is possible by using a cumbersome union. Maybe that is easier to solve on the client side.<BR><BR>Month will return the numeral for each month, so you have to translate that in your VB-code (using monthname for instance).<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts