Microsoft SQL Server DateTime 轉換格式

摘要:Microsoft SQL Server DateTime 轉換格式

SELECT getdate()        --2011-08-17 12:10:51.963
, CONVERT(varchar, getdate(), 120 ) as '120'    --2011-08-17 12:08:24
, replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','') as '120 replace'  --20110817120824
, CONVERT(varchar(17) , getdate(), 111 ) as '111'   --2011/08/17
, CONVERT(varchar(17) , getdate(), 112 ) as '112'   --20110817
, CONVERT(varchar(17) , getdate(), 102 ) as '102'   --2011.08.17
, CONVERT(varchar(17) , getdate(), 101 ) as '101'   --08/17/2011
, CONVERT(varchar(17) , getdate(), 103 ) as '103'   --17/08/2011
, CONVERT(varchar(17) , getdate(), 104 ) as '104'   --17.08.2011
, CONVERT(varchar(17) , getdate(), 105 ) as '105'   --17-08-2011
, CONVERT(varchar(17) , getdate(), 106 ) as '106'   --17 08 2011
, CONVERT(varchar(17) , getdate(), 107 ) as '107'   --08 17, 2011
, CONVERT(varchar(17) , getdate(), 108 ) as '108'   --12:10:18
, CONVERT(varchar(17) , getdate(), 109 ) as '109'   --08 17 2011 12:10:
, CONVERT(varchar(17) , getdate(), 110 ) as '110'   --08-17-2011
, CONVERT(varchar(17) , getdate(), 113 ) as '113'   --17 08 2011 1
, CONVERT(varchar(17) , getdate(), 114 ) as '114'   --9:46:18.177