I believe this should be a simple solution, but it's hard for me to find anything on it ...
So: how do I get from datetimeto varcharwith dd-MMM-yyyy format?
datetime
varchar
Eg: my_date --> '29-May-2012'
The closure I managed to find
convert(varchar(20),my_date,105) --> '29-05-2012'
Yes, I need to do this correctly in T-SQL.
Bet you can't wait for SQL Server 2012 (it might still be the right answer for other readers):
SELECT FORMAT(GETDATE(), 'dd-MMM-yyyy');
At the same time, this format is not supported initially, but from http://databases.aspfaq.com/database/what-are-the-valid-styles-for-converting-datetime-to-string.html the closest is probably the following :
SELECT REPLACE(CONVERT(CHAR(11), GETDATE(), 106), ' ', '-');
:
SELECT replace(convert(char(11), getdate(), 113), ' ', '-')
SELECT replace(convert(char(11), getdate(), 106), ' ', '-')