Different Date Time Format in sql server



Article discuss about different date formatting in sql server
  • Date  formatting in sql
  • Date time formatting in sql
  • Time formatting in sql

Different Date Formatting
SELECT CONVERT(VARCHAR, GETDATE(), 1) 05/31/18
SELECT CONVERT(VARCHAR, GETDATE(), 2) 18.05.31
SELECT CONVERT(VARCHAR, GETDATE(), 3) 31/05/18
SELECT CONVERT(VARCHAR, GETDATE(), 4) 31.05.18
SELECT CONVERT(VARCHAR, GETDATE(), 5) 31-05-18
SELECT CONVERT(VARCHAR, GETDATE(), 6) 31 May 18
SELECT CONVERT(VARCHAR, GETDATE(), 7) May 31, 18
SELECT CONVERT(VARCHAR, GETDATE(), 10) 05-31-18
SELECT CONVERT(VARCHAR, GETDATE(), 11) 18/05/31
SELECT CONVERT(VARCHAR, GETDATE(), 12) 180531
SELECT CONVERT(VARCHAR, GETDATE(), 23) 2018-05-31
SELECT CONVERT(VARCHAR, GETDATE(), 101) 05/31/2018
SELECT CONVERT(VARCHAR, GETDATE(), 102) 2018.05.31
SELECT CONVERT(VARCHAR, GETDATE(), 103) 31/05/2018
SELECT CONVERT(VARCHAR, GETDATE(), 104) 31.05.2018
SELECT CONVERT(VARCHAR, GETDATE(), 105) 31-05-2018
SELECT CONVERT(VARCHAR, GETDATE(), 106) 31 May 2018
SELECT CONVERT(VARCHAR, GETDATE(), 107) May 31, 2018
SELECT CONVERT(VARCHAR, GETDATE(), 110) 05-31-2018
SELECT CONVERT(VARCHAR, GETDATE(), 111) 2018/05/31
Different Time Formating
SELECT CONVERT(VARCHAR, GETDATE(), 8) 02:24:27
SELECT CONVERT(VARCHAR, GETDATE(), 14) 02:24:27:207
SELECT CONVERT(VARCHAR, GETDATE(), 24) 02:24:27
SELECT CONVERT(VARCHAR, GETDATE(), 108) 02:24:27
SELECT CONVERT(VARCHAR, GETDATE(), 114) 02:24:27:207
Different DateTime Formating
SELECT CONVERT(VARCHAR, GETDATE(), 0) May 31 2018 2:31AM
SELECT CONVERT(VARCHAR, GETDATE(), 9) May 31 2018 2:31:07:623AM
SELECT CONVERT(VARCHAR, GETDATE(), 13) 31 May 2018 02:31:07:623
SELECT CONVERT(VARCHAR, GETDATE(), 20) 2018-05-31 02:31:07
SELECT CONVERT(VARCHAR, GETDATE(), 21) 2018-05-31 02:31:07.623
SELECT CONVERT(VARCHAR, GETDATE(), 22) 05/31/18 2:31:07 AM
SELECT CONVERT(VARCHAR, GETDATE(), 25) 2018-05-31 02:31:07.623
SELECT CONVERT(VARCHAR, GETDATE(), 100) May 31 2018 2:31AM
SELECT CONVERT(VARCHAR, GETDATE(), 109) May 31 2018 2:31:07:623AM
SELECT CONVERT(VARCHAR, GETDATE(), 113) 31 May 2018 02:31:07:623
SELECT CONVERT(VARCHAR, GETDATE(), 120) 2018-05-31 02:31:07
SELECT CONVERT(VARCHAR, GETDATE(), 121) 2018-05-31 02:31:07.623
SELECT CONVERT(VARCHAR, GETDATE(), 126) 2018-05-31T02:31:07.623
SELECT CONVERT(VARCHAR, GETDATE(), 127) 2018-05-31T02:31:07.623

No comments:

Post a comment