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
 General SQL Server Forums
 New to SQL Server Programming
 converting a date into a year quarter

Author  Topic 

Trininole
Yak Posting Veteran

83 Posts

Posted - 2009-11-12 : 14:53:37
How would i create a separate column using sql where i am converting a date to a year quarter?? For example, the date "2005-07-03" would be the year quarter "20053" as that date july 3rd, 2005 would be in the third quarter of 2005. Is there a way of converting that date to the year quarter?

Roger DeFour

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-12 : 15:04:30
[code]
SELECT CONVERT(char(4),DATEPART(YY, GetDate()))
+'0'
+CONVERT(CHAR(1),DATEPART(Q, GetDate()))

[/code]


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-13 : 09:58:47
Any idea if this worked for you or not

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -