?
Solved

GROUP by SMALLDATETIME field

Posted on 2005-02-28
2
Medium Priority
?
551 Views
Last Modified: 2010-05-18
I am needing to group a SMALLDATETIME field by YEAR and MONTH (no day needed).  The format of the DATE field below is MM/DD/YYYY.  Can someone provide the syntax for doing this via a select query?

Here is the table I need to do this on.

RECORD                      int      4      0
[ITEM NUMBER]      nvarchar      10      1
[INV NUMBER]      nvarchar      25      1
[DATE]                      smalldatetime      4      1   <----------this is the field I need to group on
[ACCT NUMBER]      nvarchar      50      1
[ITEM DESC]      nvarchar      255      1
QTY                      int      4      1
CITY                      nvarchar      50      1
STATE                      nvarchar      4      1
ZIP                      nvarchar      12      1

Let me know if any more info is needed.

Saladart
0
Comment
Question by:saladart
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 13424834
Select CONVERT(CHAR(6), [DATE], 112) AS YYYYMM
From Table1
GROUP BY CONVERT(CHAR(6), [DATE], 112) AS YYYYMM
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 2000 total points
ID: 13424839
Let's try that again:
Select CONVERT(CHAR(6), [DATE], 112) AS YYYYMM
From Table1
GROUP BY CONVERT(CHAR(6), [DATE], 112)
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question