日期:2014-05-17 浏览次数:20790 次
if object_id('[TB]') is not null drop table [TB]
go
create table [TB] (date1 numeric(7,2),date2 numeric(7,2))
insert into [TB]
select 5.30,9.0 union all
select 14.55,2.32
select * from [TB]
SELECT REPLACE(CONVERT(VARCHAR, date1), '.', ':') AS date1 ,
REPLACE(CONVERT(VARCHAR, date2), '.', ':') AS date2 ,
DATEDIFF(mi, CONVERT(TIME, REPLACE(CONVERT(VARCHAR, date1), '.', ':')),
CONVERT(TIME, REPLACE(CONVERT(VARCHAR, date2), '.', ':'))) AS [date2-date1]
FROM dbo.TB
/*
date1 date2 date2-date1
5:30 9:00 210
14:55 2:32 -743*/