May 16, 2014 at 6:17 am
Hi Friends,
i ve the date part like '2014-04-01' when i show output like 'apr-14'
how to make that?
May 16, 2014 at 6:33 am
DECLARE @dt DATETIME;
SET @dt = GETDATE();
SELECT DATENAME(month,@dt), YEAR(@dt)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 16, 2014 at 6:38 am
Borrowing heavily from Gail to give the results in the same column with a two digit year
DECLARE @dt DATETIME;
SET @dt = GETDATE();
SELECT DATENAME(month,@dt)+'-'+ right(YEAR(@dt),2)
How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537
May 16, 2014 at 6:40 am
STUFF(STUFF(CONVERT(varchar(9),[date],6),1,3,''),4,1,'-')
Far away is close at hand in the images of elsewhere.
Anon.
May 16, 2014 at 9:10 am
Taking it one step further...
DECLARE @dt DATETIME;
SET @dt = '2014-04-01';
SELECT left(DATENAME(month,@dt),3)+'-'+ right(YEAR(@dt),2)
-- Itzik Ben-Gan 2001
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply