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
 Script Library
 Month Key Convert

Author  Topic 

kishoremcp
Starting Member

41 Posts

Posted - 2013-10-08 : 02:06:35
Hi,

I have the below query to convert my date to 201302 (YYYYMM).
REPLACE(RIGHT(CONVERT(VARCHAR(9), Open_Date_Month_Key, 6), 6), ' ', '-') as Month_key

I want it as Feb-13. (Month-YY)

Can anybody extend the existing query to get the required result.

Regards
Kishore

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-08 : 06:07:21
Does the existing query already give you that?
See this illustration

SELECT REPLACE(RIGHT(CONVERT(VARCHAR(9), GETDATE(), 6), 6), ' ', '-') as Month_key

output
--------------
Oct-13



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-10-08 : 07:01:57
we need to know the data type and an example value for Open_Date_Month_Key


Too old to Rock'n'Roll too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2013-10-08 : 08:01:13
Also if you want to show the result in front end application, do this formation there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -