Transact-SQL 常用到的日期時間格式轉換,方法如下:
SELECT CONVERT(VARCHAR(18) , getdate(), 100)
=> 12 31 2007 10:30AM
SELECT CONVERT(VARCHAR(10) , GETDATE(), 101 )
=> 12/31/2007
SELECT CONVERT(VARCHAR(10) , GETDATE(), 102 )
=> 2007.12.31
SELECT CONVERT(VARCHAR(10) , GETDATE(), 103 )
=> 31/12/2007
SELECT CONVERT(VARCHAR(10) , GETDATE(), 104 )
=> 31.12.2007
SELECT CONVERT(VARCHAR(10) , GETDATE(), 105 )
=> 31-12-2007
SELECT CONVERT(VARCHAR(10) , GETDATE(), 106 )
=> 31 12 2007
SELECT CONVERT(VARCHAR(11) , GETDATE(), 107 )
=> 12 31, 2007
SELECT CONVERT(VARCHAR(8) , GETDATE(), 108 )
=> 10:30:20
SELECT CONVERT(VARCHAR(25) , GETDATE(), 109)
=> 12 31 2007 10:30:20:517AM
SELECT CONVERT(VARCHAR(10) , GETDATE(), 110 )
=> 12-31-2007
SELECT CONVERT(VARCHAR(10) , GETDATE(), 111 )
=> 2007/12/31
SELECT CONVERT(VARCHAR(8) , GETDATE(), 112 )
=> 20071231
SELECT CONVERT(VARCHAR(23) , GETDATE(), 113 )
=> 31 12 2007 10:30:20:517
SELECT CONVERT(VARCHAR(12) , GETDATE(), 114 )
=> 10:30:20:517
SELECT CONVERT(VARCHAR, GETDATE(), 120 )
=> 2007-12-31 10:30:20
最後
SELECT REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR, GETDATE(), 120 ),'-',''),' ',''),':','')
=> 20071231103020
- Dec 01 Mon 2008 10:28
SQL 常用到的日期時間格式轉換
close
全站熱搜
留言列表