日期:2014-05-17 浏览次数:20541 次
create table test(start datetime,[end] datetime)
insert into test values('1900-01-01 10:00:00.000','1900-01-01 15:00:00.000')
insert into test values('1900-01-01 10:00:00.000','1900-01-01 18:00:00.000')
insert into test values('1900-01-01 10:00:00.000','1900-01-01 19:00:00.000')
insert into test values('1900-01-01 09:00:00.000','1900-01-01 23:00:00.000')
insert into test values('1900-01-01 09:00:00.000','1900-01-01 23:59:00.000')
insert into test values('2014-01-09 09:00:00.000','2014-01-09 21:00:00.000')
update test set start=DATEADD(YEAR,100,start) where CONVERT(nvarchar(100),start,23)='1900-01-01'
update test set [end]=DATEADD(YEAR,100,[end]) where CONVERT(nvarchar(100),[end],23)='1900-01-01'
update test set start=DATEADD(MINUTE,1,start) where SUBSTRING( CONVERT(nvarchar(100),start,120),12,5)='23:59'
update test set [end]=DATEADD(MINUTE,1,[end]) where SUBSTRING( CONVERT(nvarchar(100),[end],120),12,5)='23:59'
select * from test
/*
2000-01-01 10:00:00.000 2000-01-01 15:00:00.000
2000-01-01 10:00:00.000 2000-01-01 18:00:00.000
2000-01-01 10:00:00.000 2000-01-01 19:00:00.000
2000-01-01 09:00:00.000 2000-01-01 23:00:00.000
2000-01-01 09:00:00.000 2000-01-02 00:00:00.000
2014-01-09 09:00:00.000 2014-01-09 21:00:00.000
*/