日期:2014-05-18 浏览次数:20590 次
if object_id('[tb]') is not null drop table [tb] go create table [tb]([begintime] datetime,[endtime] datetime) insert [tb] select '2012-05-01','2012-05-30' go alter table tb add midtime as dateadd(dd,datediff(dd,begintime,endtime)/2,begintime) go select * from tb /** begintime endtime midtime ----------------------- ----------------------- ----------------------- 2012-05-01 00:00:00.000 2012-05-30 00:00:00.000 2012-05-15 00:00:00.000 (1 行受影响) **/