SQL时间格式转换CONVERT_GETDATE()
SQL时间格式转换:
年月日
SELECT CONVERT(varchar, GETDATE(), 102) AS DateTime
--2011.07.12
SELECT CONVERT(varchar, GETDATE(), 111) AS DateTime
--2011/07/12
SELECT CONVERT(varchar(10), GETDATE(), 120) AS DateTime
--2011-07-12
SELECT CONVERT(varchar, GETDATE(), 112) AS DateTime
--20110712
SELECT CONVERT(varchar, GETDATE(), 120) AS DateTime
--2011-07-12 16:29:02
SELECT REPLACE(REPLACE(REPLACE(CONVERT(varchar, GETDATE(), 120), '-', ''), ' ', ''), ':', '') AS DateTime
--20110712162902
月日年
SELECT CONVERT(varchar, GETDATE(), 101) AS DateTime
--07/12/2011
SELECT CONVERT(varchar, GETDATE(), 110) AS DateTime
--07-12-2011
SELECT CONVERT(varchar(10), GETDATE(), 100) AS DateTime
--07 12 2011
SELECT CONVERT(varchar, GETDATE(), 107) AS DateTime
--07 12, 2011
SELECT CONVERT(varchar, GETDATE(), 100) AS DateTime
--07 12 2011 4:24PM
SELECT CONVERT(varchar, GETDATE(), 109) AS DateTime
--07 12 2011 4:27:35:357PM
日月年
SELECT CONVERT(varchar, GETDATE(), 103) AS DateTime
--12/07/2011
SELECT CONVERT(varchar, GETDATE(), 104) AS DateTime
--12.07.2011
SELECT CONVERT(varchar, GETDATE(), 105) AS DateTime
--12-07-2011
SELECT CONVERT(varchar, GETDATE(), 106) AS DateTime
--12 07 2011
SELECT CONVERT(varchar, GETDATE(), 113) AS DateTime
--12 07 2011 16:28:30:077
时间
SELECT CONVERT(varchar, GETDATE(), 108) AS DateTime
--16:27:13
SELECT CONVERT(varchar, GETDATE(), 114) AS DateTime
--16:28:47:187
SELECT CONVERT(varchar, GETDATE(), 102) AS DateTime
--2011.07.12
SELECT CONVERT(varchar, GETDATE(), 111) AS DateTime
--2011/07/12
SELECT CONVERT(varchar(10), GETDATE(), 120) AS DateTime
--2011-07-12
SELECT CONVERT(varchar, GETDATE(), 112) AS DateTime
--20110712
SELECT CONVERT(varchar, GETDATE(), 120) AS DateTime
--2011-07-12 16:29:02
SELECT REPLACE(REPLACE(REPLACE(CONVERT(varchar, GETDATE(), 120), '-', ''), ' ', ''), ':', '') AS DateTime
--20110712162902
月日年
SELECT CONVERT(varchar, GETDATE(), 101) AS DateTime
--07/12/2011
SELECT CONVERT(varchar, GETDATE(), 110) AS DateTime
--07-12-2011
SELECT CONVERT(varchar(10), GETDATE(), 100) AS DateTime
--07 12 2011
SELECT CONVERT(varchar, GETDATE(), 107) AS DateTime
--07 12, 2011
SELECT CONVERT(varchar, GETDATE(), 100) AS DateTime
--07 12 2011 4:24PM
SELECT CONVERT(varchar, GETDATE(), 109) AS DateTime
--07 12 2011 4:27:35:357PM
日月年
SELECT CONVERT(varchar, GETDATE(), 103) AS DateTime
--12/07/2011
SELECT CONVERT(varchar, GETDATE(), 104) AS DateTime
--12.07.2011
SELECT CONVERT(varchar, GETDATE(), 105) AS DateTime
--12-07-2011
SELECT CONVERT(varchar, GETDATE(), 106) AS DateTime
--12 07 2011
SELECT CONVERT(varchar, GETDATE(), 113) AS DateTime
--12 07 2011 16:28:30:077
时间
SELECT CONVERT(varchar, GETDATE(), 108) AS DateTime
--16:27:13
SELECT CONVERT(varchar, GETDATE(), 114) AS DateTime
--16:28:47:187