SQLServer 日期,字串格式轉換

來源:互聯網
上載者:User
SELECT   convert(char,你的日期欄位,120)   as   date2   FROM   table

mssql預設以系統時間格式輸出,你可以調整系統的時間格式來解決

當然是在程式裡解決比較靈活,convert(char,date,N)輸出的各中樣式
N   日期樣式  
0   04   2   2005   9:06AM  
1   04/02/05  
2   05.04.02  
3   02/04/05  
4   02.04.05  
5   02-04-05  
6   02   04   05  
7   04   02,   05  
8   09:06:18  
9   04   2   2005   9:06:18:857AM  
10   04-02-05  
11   05/04/02  
12   050402  
13   02   04   2005   09:06:18:857  
14   09:06:18:857  
20   2005-04-02   09:06:18  
21   2005-04-02   09:06:18.857  
22   04/02/05   9:06:18   AM  
23   2005-04-02  
24   09:06:18  
25   2005-04-02   09:06:18.857  
100   04   2   2005   9:06AM  
101   04/02/2005  
102   2005.04.02  
103   02/04/2005  
104   02.04.2005  
105   02-04-2005  
106   02   04   2005  
107   04   02,   2005  
108   09:06:18  
109   04   2   2005   9:06:18:857AM  
110   04-02-2005  
111   2005/04/02  
112   20050402  
113   02   04   2005   09:06:18:857  
114   09:06:18:857  
120   2005-04-02   09:06:18  
121   2005-04-02   09:06:18.857  
126   2005-04-02T09:06:18.857

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.