SQL Query : Date in DD MMM YYYY format example

Today i got a requirement to convert my date into day month and year format. I have used below query for that.
This kind of format mainly we are going to use in the PIVOT Queries as well as dynamics queries of SQL Server.


declare @date date
set @date=GETDATE()
print (cast(day(@date) as varchar))+' '+convert(char(3), @date, 0)+ ' '+       
cast(year(@date) as varchar)        



Output of the

18 Dec 2012

Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar