日期:2014-05-17 浏览次数:20503 次
--> 测试数据:[test] if object_id('[test]') is not null drop table [test] create table [test]( [员工] varchar(2), [上下班时间] varchar(50) ) insert [test] select 'aa','2012-05-01 09:00--2012-05-01 17:30' union all select 'aa','2012-05-02 09:00--2012-05-02 17:30' union all select 'aa','2012-05-03 09:00--2012-05-03 17:30' union all select 'aa','2012-05-04 09:00--2012-05-04 17:30' select [员工],DATEDIFF(HH,LEFT([上下班时间],16),RIGHT([上下班时间],16)) as [上下班时间] from test /* 员工 上下班时间 aa 8 aa 8 aa 8 aa 8 */