我想从DateTime列使用SQL查询只得到时间 使用SQL Server 2005和2008 默认的输出:
AttDate
==
2011-02-09 13:09:00
2011-02-09 14:10:00
我想要这样的输出:
AttDate Time
==
2011-02-09 13:09:00 13:09
2011-02-09 14:10:00 14:10
我想从DateTime列使用SQL查询只得到时间 使用SQL Server 2005和2008 默认的输出:
AttDate
==
2011-02-09 13:09:00
2011-02-09 14:10:00
我想要这样的输出:
AttDate Time
==
2011-02-09 13:09:00 13:09
2011-02-09 14:10:00 14:10
当前回答
试试这个:
select convert(nvarchar,CAST(getdate()as time),100)
其他回答
如果你想要这样的约会方式:2013年10月23日上午10:30
使用这个
SELECT CONVERT(NVARCHAR(30),getdate(), 100)
Convert()方法有3个参数
数据类型 列/值 款式:可选款式从100到114。你可以在范围内选择。依次选择可更改日期格式。
select substr(to_char('DD/MM/RRRR HH:MM:SS'),11,19) from table_name;
输出:
05:11:26
05:11:24
05:11:24
试试这个
时间日期 Select cast(getdate() as time(0)) 时间到TinyTime 选择强制转换(orig_time作为时间(0))
select AttDate,convert(char(5), AttDate, 108)[时间]从你的表名
MSSQL2012或以上版本
cast(dateadd(ms,datediff(ms, [StartDateTime], [StopDateTime]),0) as Time(0))
…或…
convert(time(0),dateadd(ms,datediff(ms, [StartDateTime], [StopDateTime]),0) )