SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Month Key Convert
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kishoremcp
Starting Member

India
39 Posts

Posted - 10/08/2013 :  02:06:35  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 10/08/2013 :  06:07:21  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Germany
8765 Posts

Posted - 10/08/2013 :  07:01:57  Show Profile  Visit webfred's Homepage  Reply with Quote
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

India
22761 Posts

Posted - 10/08/2013 :  08:01:13  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000