Sunday, July 29, 2012

SQL SERVER – Hint’s on All Date Format Using Date Code



 Most of the time we want to format date in output and most of the SQL New Developer consume time to get the desired formatted date output. Here I am sharing the entire date format in below script.

 SET NOCOUNT ON;

 SELECT CONVERT(varchar(12), GETDATE(), 100)
 SELECT CONVERT(varchar(12), GETDATE(), 101)
 SELECT CONVERT(varchar(12), GETDATE(), 102)
 SELECT CONVERT(varchar(12), GETDATE(), 103)
 SELECT CONVERT(varchar(12), GETDATE(), 104)
 SELECT CONVERT(varchar(12), GETDATE(), 105)
 SELECT CONVERT(varchar(12), GETDATE(), 106)
 SELECT CONVERT(varchar(12), GETDATE(), 107)
 SELECT CONVERT(varchar(12), GETDATE(), 108)
 SELECT CONVERT(varchar(12), GETDATE(), 109)
 SELECT CONVERT(varchar(12), GETDATE(), 110)
 SELECT CONVERT(varchar(12), GETDATE(), 111)
 SELECT CONVERT(varchar(12), GETDATE(), 112)
 SELECT CONVERT(varchar(12), GETDATE(), 113)
 SELECT CONVERT(varchar(12), GETDATE(), 114)


  
Output:

------------
Jul 29 2012
------------
07/29/2012
------------
2012.07.29
------------
29/07/2012
------------
29.07.2012


------------
29-07-2012


------------
29 Jul 2012
------------
Jul 29, 2012
------------
21:37:17
------------
Jul 29 2012
------------
07-29-2012
------------
2012/07/29
------------
20120729
------------
29 Jul 2012
------------
21:37:17:793














Like and Share to SQL Integrity Blog

No comments:

Post a Comment

Thank You !!!!