select语句
Select CONVERT(varchar(100), GETDATE(), 111): 2006/05/16
Select CONVERT(varchar(100), GETDATE(), 20): 2006-05-16 10:57:47
Select CONVERT(varchar(100), GETDATE(), 21): 2006-05-16 10:57:47.157
Select CONVERT(varchar(100), GETDATE(), 25): 2006-05-16 10:57:47.250
Select CONVERT(varchar(100), GETDATE(), 112): 20060516
Select CONVERT(varchar(100), GETDATE(), 120): 2006-05-16 10:57:49
Select CONVERT(varchar(100), GETDATE(), 121): 2006-05-16 10:57:49.700
string.Format语句
DateTime dt = new DateTime(2017,4,1,13,16,32,108);
string.Format("{0:yyyy/MM/dd HH:mm:ss.fff}",dt); //2017/04/01 13:16:32.108
string.Format("{0:yyyyMMdd}", dt); //20170401
dt.ToString语句
dt.ToString("yyyy/MM/dd HH:mm:ss.fff"); //2017/04/01 13:16:32.108
dt.ToString("yyyyMMdd"); //20170401 |