SQL Server常用的日期格式轉換

SQL Server中文版的預設的日期字串datetime格式是yyyy-mm-dd Thh:mm:ss.mmm
例如:
select getdate()
2004-09-12 11:06:08.177
找相關資料時發現有以下範例,節錄下來以備日後參考用。

select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08

select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
20040912110608

select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12

select CONVERT(varchar(12) , getdate(), 112 )
20040912

select CONVERT(varchar(12) , getdate(), 102 )
2004.09.12

select CONVERT(varchar(12) , getdate(), 101 )
09/12/2004

select CONVERT(varchar(12) , getdate(), 103 )
12/09/2004

select CONVERT(varchar(12) , getdate(), 104 )
12.09.2004

select CONVERT(varchar(12) , getdate(), 105 )
12-09-2004

select CONVERT(varchar(12) , getdate(), 106 )
12 09 2004

select CONVERT(varchar(12) , getdate(), 107 )
09 12, 2004

select CONVERT(varchar(12) , getdate(), 108 )
11:06:08

select CONVERT(varchar(12) , getdate(), 109 )
09 12 2004 1

select CONVERT(varchar(12) , getdate(), 110 )
09-12-2004

select CONVERT(varchar(12) , getdate(), 113 )
12 09 2004 1

select CONVERT(varchar(12) , getdate(), 114 )
11:06:08.177
引用通告地址: 點擊獲取引用地址
評論: 1 | 引用: 3 | 閱讀: 4002 | 列印
Designerwatches [ 2010-05-06 00:34 網址 | 回覆 | 編輯 刪除 ]
Wholesale fashion watches designs and distributes Designer watches, Bvlgari Watches, Rolex Watches, and home furnishings as well, but their Cartier Handbags remain among their most well-known and sought-after Gucci Handbags. If you are looking for a reason to choose a Replica Handbags, you need look no further than the many celebrities who have chosen products designed by the teams of the Fendi Handbags.
  • 1 
發表評論
暱 稱: 密 碼:
網 址: E - mail:
驗證碼: 驗證碼圖片 選 項:
內 容: