日期:2014-05-18 浏览次数:20569 次
create table tbTimesheet (Id int, WorkDate datetime, StartTime datetime) insert into tbTimesheet select 1, '2012-02-12 00:00:00.000', '2012-02-16 08:00:00.000' union all select 2, '2012-03-13 00:00:00.000', '2012-03-16 08:00:00.000' update tbTimesheet set StartTime=convert(varchar,WorkDate,23)+' '+convert(varchar,StartTime,108) select * from tbTimesheet Id WorkDate StartTime ----------- ----------------------- ----------------------- 1 2012-02-12 00:00:00.000 2012-02-12 08:00:00.000 2 2012-03-13 00:00:00.000 2012-03-13 08:00:00.000 (2 row(s) affected)
------解决方案--------------------
create table tbTimesheet(Id int,WorkDate datetime,StartTime datetime) insert into tbTimesheet values(1, '2012-02-12 00:00:00.000', '2012-02-16 08:00:00.000') insert into tbTimesheet values(2, '2012-03-13 00:00:00.000', '2012-03-16 08:00:00.000') update tbTimesheet set StartTime = convert(varchar(10),WorkDate,120) + ' ' + convert(varchar(8),StartTime,108) select * From tbTimesheet drop table tbTimesheet /* Id WorkDate StartTime ----------- ------------------------------------------------------ ------------------------------------------------------ 1 2012-02-12 00:00:00.000 2012-02-12 08:00:00.000 2 2012-03-13 00:00:00.000 2012-03-13 08:00:00.000 (所影响的行数为 2 行) */