Click here to Skip to main content
15,884,720 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Hi friends

i have one date like 25/12/2014 and my problem is i want to dec 2014 formate how to possible in sql server
thanks to advance
Posted
Comments
Basmeh Awad 4-Feb-14 8:14am    
TRY THIS SOLUTION...

SQL
select substring(CONVERT(VARCHAR(12), COLUMNNAME, 106),3,10) AS date from YOURTABLE

which ever date format you want[^]
 
Share this answer
 
v2
SQL
select convert(nvarchar(max),getdate(),106)



SQL
select substring(convert(nvarchar(max),getdate(),106),3,100)
 
Share this answer
 
v2
Comments
[no name] 4-Feb-14 7:47am    
no date only month and year
King Fisher 4-Feb-14 7:51am    
select substring(convert(nvarchar(max),getdate(),106),3,100)
Try

SQL
SELECT  FORMAT(Now(),'MMM YYYY') AS ConvertedColumnName
FROM TableName;


Note : Change the Now() function to the Datetime value

Keep the below link as a reference for all kind of Date Conversions.

http://www.sql-server-helper.com/sql-server-2012/format-function-vs-convert-function.aspx[^]
 
Share this answer
 
v2
Comments
King Fisher 5-Feb-14 0:07am    
sir
'FORMAT' is not a recognized built-in function name in sqlserver 2008,sql server 2005.
JoCodes 5-Feb-14 0:17am    
Thanks for pointing out , it works in 2012 SQL Server . I missed out the SQL 2005 Tag.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900