Example : Convert Date in various Format
SELECT GETDATE() --
2012-07-16 13:00:38.280
--DATE FORMAT
SELECT CONVERT(VARCHAR, GETDATE(), 1) --Result will be
07/16/12
SELECT CONVERT(VARCHAR, GETDATE(), 2) --Result will be
12.07.16
SELECT CONVERT(VARCHAR, GETDATE(), 3) --Result will be
16/07/12
SELECT CONVERT(VARCHAR, GETDATE(), 4) --Result will be
16.07.12
SELECT CONVERT(VARCHAR, GETDATE(), 5) --Result will be
16-07-12
SELECT CONVERT(VARCHAR, GETDATE(), 6) --Result will be 16
Jul 12
SELECT CONVERT(VARCHAR, GETDATE(), 7) --Result will be
Jul 16, 12
SELECT CONVERT(VARCHAR, GETDATE(), 10) --Result will be
07-16-12
SELECT CONVERT(VARCHAR, GETDATE(), 11) --Result will be
12/07/16
SELECT CONVERT(VARCHAR, GETDATE(), 101) --Result will be
07/16/2012
SELECT CONVERT(VARCHAR, GETDATE(), 102) --Result will be
2012.07.16
SELECT CONVERT(VARCHAR, GETDATE(), 103) --Result will be
16/07/2012
SELECT CONVERT(VARCHAR, GETDATE(), 104) --Result will be
16.07.2012
SELECT CONVERT(VARCHAR, GETDATE(), 105) --Result will be
16-07-2012
SELECT CONVERT(VARCHAR, GETDATE(), 106) --Result will be 16
Jul 2012
SELECT CONVERT(VARCHAR, GETDATE(), 107) --Result will be
Jul 16, 2012
SELECT CONVERT(VARCHAR, GETDATE(), 110) --Result will be
07-16-2012
SELECT CONVERT(VARCHAR, GETDATE(), 111) --Result will be
2012/07/16
--TIME FORMAT
SELECT CONVERT(VARCHAR, GETDATE(), 8) --Result will be
13:19:27
SELECT CONVERT(VARCHAR, GETDATE(), 9) --Result will be
Jul 16 2012 1:19:35:720PM
SELECT CONVERT(VARCHAR, GETDATE(), 14) --Result will be
13:19:42:610
No comments:
Post a Comment