Please disable your adblock and script blockers to view this page
 

Date format in sql server

Introduction: In previous article i explained how to Take automatic backup of Sql server Database and Copy all data from one database table to another database table in Sql Server and How to delete all tables from Sql server Database and How to delete all stored procedures from sql server database and How to concatenate two strings in Sql Server

While working on application we may require to display date in various formats on the front end. Here is the way to help you get date as per your requirement.I have listed various Date Format available in  Sql Server Database

SELECT CONVERT(VARCHAR,GETDATE(),100) --Output:  Feb 18 2011 10:39PM

SELECT CONVERT(VARCHAR,GETDATE(),101) --Output:  02/18/2011


SELECT CONVERT(VARCHAR,GETDATE(),102) --Output:  2011.02.18

SELECT CONVERT(VARCHAR,GETDATE(),103) --Output:  18/02/2011

SELECT CONVERT(VARCHAR,GETDATE(),104) --Output:  18.02.2011

SELECT CONVERT(VARCHAR,GETDATE(),105) --Output:  18-02-2011

SELECT CONVERT(VARCHAR,GETDATE(),106) --Output:  18 Feb 2011

SELECT CONVERT(VARCHAR,GETDATE(),107) --Output:  Feb 18, 2011

SELECT CONVERT(VARCHAR,GETDATE(),108) --Output:  22:40:38

SELECT CONVERT(VARCHAR,GETDATE(),109) --Output:  Feb 18 2011 10:40:42:500PM

SELECT CONVERT(VARCHAR,GETDATE(),110) --Output:  02-18-2011

SELECT CONVERT(VARCHAR,GETDATE(),111) --Output:  2011/02/18

SELECT CONVERT(VARCHAR,GETDATE(),112) --Output:  20110218

SELECT CONVERT(VARCHAR,GETDATE(),113) --Output:  18 Feb 2011 22:41:02:327

SELECT CONVERT(VARCHAR,GETDATE(),114) --Output:  22:41:07:640

SELECT CONVERT(VARCHAR,GETutcDATE(),114) --Output:  15:41:34:170



webcodeexpert.com



webcodeexpert.com is protected by copyscape. So do not copy


Previous
Next Post »

If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily.. ConversionConversion EmoticonEmoticon