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)
 Get Quarter based on month name

Author  Topic 

prashanthpulgal
Starting Member

1 Post

Posted - 2002-11-24 : 02:32:14
Hi,

Can any one tell me how to get the quarter to which the month belongs to in SQL Server 2000 using the month name.

Using DATEPART(Qq,getdate()) it is possible but it is basec on date.HOw to get based on mont name

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-11-24 : 06:30:24
SELECT CASE WHEN MonthName IN('January','February','March') THEN 1
WHEN MonthName IN('April','May','June') THEN 2
WHEN MonthName IN('July','August','September') THEN 3
ELSE 4 END AS Quarter


Why are you only storing the month name instead of an actual date value?

Edited by - robvolk on 11/24/2002 06:30:49
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-11-24 : 11:41:48
SELECT DatePart(q,CAST((@strMonth + '01 01') As DateTime))

Go to Top of Page
   

- Advertisement -