Thursday, December 16, 2010

SQL Tips : Converting SQL Server Date time format

This morning, one of my friend asked me "how to convert SQL Server DateTime format into other format?".
 Example: from this 2010-12-17 (yyyy-mm-dd) format  into 17-DES-2010 (dd-Mon-yyyy) format.

and here's my answer:
SELECT UPPER(REPLACE(CONVERT(VARCHAR(11), GETDATE(), 106), ' ', '-')) AS [DD-Mon-YYYY]

and its worked well

No comments:

Post a Comment

Finally, C# 9 record, the equivalent of Scala's case class

While C# is a wonderful programming language, there is something that I would like to see to make our life programmer easier. If you are fam...