Skip to content

Yearly Archives: 2010

Sql时间转varchar字符串

 

CONVERT(data_type,expression_r_r[,style])

语句及查询结果:

SELECT CONVERT(varchar(100), GETDATE_r(), 0): 05 16 2006 10:57AM

SELECT CONVERT(varchar(100), GETDATE_r(), 1): 05/16/06

SELECT CONVERT(varchar(100), GETDATE_r(), 2): 06.05.16

SELECT CONVERT(varchar(100), GETDATE_r(), 3): 16/05/06

SELECT CONVERT(varchar(100), GETDATE_r(), 4): 16.05.06

SELECT CONVERT(varchar(100), GETDATE_r(), 5): 16-05-06

SELECT CONVERT(varchar(100), GETDATE_r(), 6): 16 05 06

SELECT CONVERT(varchar(100), GETDATE_r(), 7): 05 16, 06

SELECT CONVERT(varchar(100), GETDATE_r(), 8): 10:57:46

SELECT CONVERT(varchar(100), GETDATE_r(), 9): 05 16 2006 10:57:46:827AM

SELECT CONVERT(varchar(100), GETDATE_r(), 10): 05-16-06

SELECT CONVERT(varchar(100), GETDATE_r(), 11): 06/05/16

SELECT CONVERT(varchar(100), GETDATE_r(), 12): 060516

SELECT CONVERT(varchar(100), GETDATE_r(), 13): 16 05 2006 10:57:46:937

SELECT CONVERT(varchar(100), GETDATE_r(), 14): 10:57:46:967

SELECT CONVERT(varchar(100), GETDATE_r(), 20): 2006-05-16 10:57:47

SELECT CONVERT(varchar(100), GETDATE_r(), 21): 2006-05-16 10:57:47.157

SELECT CONVERT(varchar(100), GETDATE_r(), 22): 05/16/06 10:57:47 AM

SELECT CONVERT(varchar(100), GETDATE_r(), 23): 2006-05-16

SELECT CONVERT(varchar(100), GETDATE_r(), 24): 10:57:47

SELECT CONVERT(varchar(100), GETDATE_r(), 25): 2006-05-16 10:57:47.250

SELECT CONVERT(varchar(100), GETDATE_r(), 100): 05 16 2006 10:57AM

SELECT CONVERT(varchar(100), GETDATE_r(), 101): 05/16/2006

SELECT CONVE