--Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86) --Jul 9 2008 14:43:34 --Copyright (c) 1988-2008 Microsoft Corporation --Developer Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3, v.3300) SELECT CAST('2007-05-08 12:35:29' AS time(0)) AS 'time'
--Jul 9 2008 14:43:34
--Copyright (c) 1988-2008 Microsoft Corporation
--Developer Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3, v.3300)
SELECT
CAST('2007-05-08 12:35:29' AS time(0)) AS 'time'
time
----------------
12:35:29(1 行受影响)
进行时间比较操作也方便!
select convert(varchar(10),getdate(),102) --2007.06.15
select convert(varchar(10),getdate(),103) --15/06/2007
select convert(varchar(10),getdate(),104) --15.06.2007
select convert(varchar(10),getdate(),105) --15-06-2007
select convert(varchar(10),getdate(),106) --15 06 2007
select convert(varchar(10),getdate(),107) --06-15,200
select convert(varchar(10),getdate(),108) --10:06:46 当前时间
select convert(varchar(10),getdate(),109) --06 15 2007 或者9
select convert(varchar(10),getdate(),110) --06-15-2007
select convert(varchar(10),getdate(),111) --2007/06/15
select convert(varchar(10),getdate(),112) --20070615
select convert(varchar(10),getdate(),113) --15 06 2007 或者13
select convert(varchar(10),getdate(),114) --10:10:37:0select convert(varchar(10),getdate(),120) --2007-06-15 或20
select convert(varchar(30),getdate(),121) --2007-06-15 10:11:45.040 或21
select convert(varchar(30),getdate(),126) --2007-06-15T10:12:44:603
select convert(varchar(50),getdate(),127) --2007-06-15T10:14:35:433 说带时区
select convert(varchar(40),getdate(),130) --回历dd mon yyyy hh:mi:ss:mmmAM
select convert(varchar(30),getdate(),131) --30/05/1428 10:17:19:470AM
自己看吧
用的时候用convert转换吧