SQL "Group By" Date question

Results 1 to 2 of 2

Thread: SQL "Group By" Date question

  1. #1
    Join Date
    Dec 1969

    Default SQL "Group By" Date question

    Could anyone please help me with the correct asp syntax to group records by StartDate (dd/mm/yyyy), using the month as the group filter.<BR><BR>I want to pull all records from the database - <BR>Group By the month of the StartDate -<BR>Order each group by Phone Number.<BR><BR>Thank you ahead of time,<BR>Tiff

  2. #2
    Join Date
    Dec 1969

    Default Month only?

    ?Not the year, as well?<BR><BR>Anyway, I think in both Access and SQL Server (and you don&#039;t mention what DB you are using, and this is a DB-specific issue), you can do:<BR><BR>SELECT ... FROM table WHERE ...<BR>GROUP BY Month(someDateTimeField)<BR>ORDER BY Month(someDateTimeField)<BR><BR><BR>The MONTH( ) function will extract just the month from the field.<BR><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