--生成测试数据
create table #t(id int,start_time datetime,duration varchar(8))
insert into #t select 1,'2005-7-12 4:02:00','00:29:00'
insert into #t select 2,'2005-7-12 4:31:00','00:24:00'
insert into #t select 3,'2005-7-12 5:00:10','00:10:00'
insert into #t select 4,'2005-7-12 5:30:00','00:30:00'
--执行查询
select id,start_time+cast(duration as datetime) from #t
--输出结果
1 2005-07-12 04:31:00.000
2 2005-07-12 04:55:00.000
3 2005-07-12 05:10:10.000
4 2005-07-12 06:00:00.000
create table #t(id int,start_time datetime,duration varchar(8))
insert into #t select 1,'2005-7-12 4:02:00','00:29:00'
insert into #t select 2,'2005-7-12 4:31:00','00:24:00'
insert into #t select 3,'2005-7-12 5:00:10','00:10:00'
insert into #t select 4,'2005-7-12 5:30:00','00:30:00'
--执行查询
select id,start_time+cast(duration as datetime) from #t
--输出结果
1 2005-07-12 04:31:00.000
2 2005-07-12 04:55:00.000
3 2005-07-12 05:10:10.000
4 2005-07-12 06:00:00.000
解决方案 »
- 将 expression 转换为数据类型 datetime 时发生算术溢出错误,如果是数据问题改怎么解决?
- 【求助帖】请问这个套在手机上的是什么高级东东?
- UPDATE的问题
- 请教大家一个连接查询的SQL文
- 我的sql server 2000 不能进行数据还原了?
- 关于统计的。请邹健等兄弟进来帮忙解决下。
- mssql 2000数据库连接提示:在建立与服务器的连接时出错,在连接到SQL Server 2005时,在默认的设置下SQL Server不允许进行远程连接
- 这个语句想改成SQL SERVER 大家有什么方法吗?
- 一个super simple的问题,快进
- 多步ole db操作产生错误
- 更新数据问题。。请大虾帮忙看看
- sql查询替换语句,请高人指点
create table #t(id int,start_time datetime,duration varchar(8))
insert into #t select 1,'2005-7-12 4:02:00','00:29:00'
insert into #t select 2,'2005-7-12 4:31:00','00:24:00'
insert into #t select 3,'2005-7-12 5:00:10','00:10:00'
insert into #t select 4,'2005-7-12 5:30:00','00:30:00'
--执行查询
select
id,start_time+cast(duration as datetime)
from
#t
where
start_time+cast(duration as datetime) between '2005-7-12 4:30:00' and '2005-7-12 5:00:00'
--输出结果
1 2005-07-12 04:31:00.000
2 2005-07-12 04:55:00.000
create table #t(id int,start_time datetime,duration varchar(8))
insert into #t select 1,'2005-7-12 4:02:00','00:29:00'
insert into #t select 2,'2005-7-12 4:31:00','00:24:00'
insert into #t select 3,'2005-7-12 5:00:10','00:10:00'
insert into #t select 4,'2005-7-12 5:30:00','00:30:00'
--执行查询
select
id,start_time+cast(duration as datetime)
from
#t
where
start_time+ duration between '2005-7-12 4:30:00' and '2005-7-12 5:00:00' 会自己转换的