[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

Another SQL Query

Hi all i have the following query, but i now need it grouped into weeks and not months,

Please help

SELECT     TOP (100) PERCENT DATENAME(month, createdon) + DATENAME(year, createdon) AS Month, projcode, result, COUNT(*) AS Expr2, createdon
FROM         dbo.dmsproj
WHERE     (createdon >= DATEADD(MONTH, - 12, CONVERT(datetime, CONVERT(varchar(8), GETDATE(), 120) + '01', 120)))
GROUP BY createdon, DATENAME(month, createdon) + DATENAME(year, createdon), projcode, result
0
pepps11976
Asked:
pepps11976
1 Solution
 
Ephraim WangoyaCommented:

Use
DATENAME(week, createdon)

But remember this will just give you the week number of the year
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now