常用转换格式
yyyy-mm-dd Thh:mm:ss
SELECT CONVERT(VARCHAR(20),GETDATE(),20) → 2021-06-27 16:58:00
yyyy-mm-dd(
SELECT CONVERT(VARCHAR(20),GETDATE(),23) → 2021-06-27
Thh:mm:ss
SELECT CONVERT(VARCHAR(20),GETDATE(),24) → 17:00:20
yyyymmdd
SELECT CONVERT(VARCHAR(20),GETDATE(),112) → 20210627
yymmdd
SELECT CONVERT(VARCHAR(20),GETDATE(),12) → 210627
全部转换格式示例
复制
SELECT CONVERT(VARCHAR(20), GETDATE(), 0) → Jun 27 2021 5:07PM
SELECT CONVERT(VARCHAR(20), GETDATE(), 1) → 06/27/21
SELECT CONVERT(VARCHAR(20), GETDATE(), 2) → 21.06.27
SELECT CONVERT(VARCHAR(20), GETDATE(), 3) → 27/06/21
SELECT CONVERT(VARCHAR(20), GETDATE(), 4) → 27.06.21
SELECT CONVERT(VARCHAR(20), GETDATE(), 5) → 27-06-21
SELECT CONVERT(VARCHAR(20), GETDATE(), 6) → 27 Jun 21
SELECT CONVERT(VARCHAR(20), GETDATE(), 7) → Jun 27, 21
SELECT CONVERT(VARCHAR(20), GETDATE(), 8) → 17:16:23
SELECT CONVERT(VARCHAR(30), GETDATE(), 9) → Jun 27 2021 5:16:59:660PM
SELECT CONVERT(VARCHAR(30), GETDATE(), 10) → 06-27-21
SELECT CONVERT(VARCHAR(30), GETDATE(), 11) → 21/06/27
SELECT CONVERT(VARCHAR(30), GETDATE(), 12) → 210627
SELECT CONVERT(VARCHAR(30), GETDATE(), 13) → 27 Jun 2021 17:19:30:257
SELECT CONVERT(VARCHAR(30), GETDATE(), 14) → 17:19:58:850
SELECT CONVERT(VARCHAR(30), GETDATE(), 20) → 2021-06-27 17:20:41
SELECT CONVERT(VARCHAR(30), GETDATE(), 21) → 2021-06-27 17:21:24.623
SELECT CONVERT(VARCHAR(30), GETDATE(), 22) → 06/27/21 5:21:49 PM
SELECT CONVERT(VARCHAR(30), GETDATE(), 23) → 2021-06-27
SELECT CONVERT(VARCHAR(30), GETDATE(), 24) → 17:22:40
SELECT CONVERT(VARCHAR(30), GETDATE(), 25) → 2021-06-27 17:23:00.517
SELECT CONVERT(VARCHAR(30), GETDATE(), 100) → Jun 27 2021 5:23PM
SELECT CONVERT(VARCHAR(30), GETDATE(), 101) → 06/27/2021
SELECT CONVERT(VARCHAR(30), GETDATE(), 102) → 2021.06.27
SELECT CONVERT(VARCHAR(30), GETDATE(), 103) → 27/06/2021
SELECT CONVERT(VARCHAR(30), GETDATE(), 104) → 27.06.2021
SELECT CONVERT(VARCHAR(30), GETDATE(), 105) → 27-06-2021
SELECT CONVERT(VARCHAR(30), GETDATE(), 106) → 27 Jun 2021
SELECT CONVERT(VARCHAR(30), GETDATE(), 107) → Jun 27, 2021
SELECT CONVERT(VARCHAR(30), GETDATE(), 108) → 17:26:59
SELECT CONVERT(VARCHAR(30), GETDATE(), 109) → Jun 27 2021 5:27:19:357PM
SELECT CONVERT(VARCHAR(30), GETDATE(), 110) → 06-27-2021
SELECT CONVERT(VARCHAR(30), GETDATE(), 111) → 2021/06/27
SELECT CONVERT(VARCHAR(30), GETDATE(), 112) → 20210627
SELECT CONVERT(VARCHAR(30), GETDATE(), 113) → 27 Jun 2021 17:28:53:770
SELECT CONVERT(VARCHAR(30), GETDATE(), 114) → 17:29:13:777
SELECT CONVERT(VARCHAR(30), GETDATE(), 120) → 2021-06-27 17:29:53
SELECT CONVERT(VARCHAR(30), GETDATE(), 121) → 2021-06-27 17:30:16.137
SELECT CONVERT(VARCHAR(30), GETDATE(), 126) → 2021-06-27T17:30:41.590
SELECT CONVERT(VARCHAR(30), GETDATE(), 131) → 18/11/1442 5:31:37:647PM