.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

Format Datetime to 21 st Sep 2010

Posted By: Deco     Posted Date: September 21, 2010    Points:2   Category :Sql Server
How to get the date in the below format

21 st Sep 2010

Can any one give me a function?

Responses
Author: Syed Shakeer Hussain             
Posted Date: September 21, 2010     Points: 5   

Hi Alwyn,

Use the below Query





SELECT CONVERT(VARCHAR(24), GETDATE(), 113)







Author: Deco             
Posted Date: September 22, 2010     Points: 5   

Syed,

in your answer "st" is missing.

please check...

Regards,
Deco
Author: Vijay Reddy             
Posted Date: October 02, 2010     Points: 5   

Alwyn,

Use the following for get st,nd,rd,th

Declare @DD int;
Declare @RES varchar(2);
Set @DD =(Select DAY(getdate()))
if(right(@DD,1) = 1 and @DD <> 11)
Set @RES = 'st'
else if(right(@DD,1) = 2 and @DD <> 12))
Set @RES = 'nd'
else if(right(@DD,1) = 3 and @DD <> 13))
Set @RES = 'rd'
else
Set @RES = 'th'


Regards,
Vij@y Reddy
Sr.Software Developer




Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend