Reputation: 28771
How to get format like 19 Dec 2012
from getdate() function in tsql
select convert(varchar(11),getdate(),?)
Upvotes: 1
Views: 2742
Reputation: 8335
-- Can use if SQL 2008 and above (precision to nanoseconds)
SELECT CONVERT(VARCHAR(12), SYSDATETIME(), 106)
-- otherwise (precision to miliseconds)
SELECT CONVERT(VARCHAR(12), GETDATE(), 106)
Upvotes: 1
Reputation: 239824
Cast and Convert lists the available formats:
106 dd mon yy
looks about right.
I'd generally avoid doing any formatting on the database. Keep dates as dates as long as possible - only convert at the last moment in displaying it to the user (similarly, for any input, prefer to convert it from string into its proper data type as early as possible)
Upvotes: 1