using getdate() in sql server to get date as "27Aug13"?

264 views Asked by At

Query to get the below as output is required.

How can I get ouput as 27AUG13 in SQL SEVER?

Please suggest

3

There are 3 answers

0
Giannis Paraskevopoulos On

The following will have spaces:

SELECT CONVERT(VARCHAR,GETDATE(),6)

You can replace spaces:

SELECT REPLACE(CONVERT(VARCHAR,GETDATE(),6),' ','')
0
Adrian Wragg On

It's a bit of a hack, but the following works:

  SELECT replace(convert(varchar(10), getdate(), 6), ' ', '')

The internal convert(varchar, getdate(), 6) returns (at least, today) "28 Aug 13", with the replace then removing the spaces.

0
Tim Schmelter On

Perhaps (works also in SQL-Server 2005 without DATE):

SELECT CONVERT(VARCHAR(12), GETDATE(),6) AS [TodaysDate] 

DEMO 28 Aug 13