Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Grouping date by month

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-04-08 : 09:17:43
Ozlem Yener writes "I have numbers, names and date. I put the sql sentence below. What I would like to do is group month and put it in a column and Sort it by month?. In access 2000 I can use format$ function for date is there any way to do this in SQL 2000. Thank you in advance.

Ozlem

SELECT purchasedate, CONVERT(CHAR(10),CAST(purchasedate -2 as smalldatetime),103) as purchasedate, month(purchasedate) as purchasedatebymonth"

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2004-04-08 : 11:00:53
What's this for?
Go to Top of Page

nricardo
Starting Member

17 Posts

Posted - 2004-04-08 : 13:20:45
look up the datepart and datename functions
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-08 : 15:17:13
SELECT
purchasedate,
DATEPART(mm,purchasedate) AS purchasemonth
FROM
purchaseinfo
GROUP BY
DATEPART(mm,purchasedate)



MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -