拼字符串成为时间,和两个计算时间点的中间值
拼字符串成为时间,和两个计算时间点的中间值
select convert(datetime,'2016-09-18 '+SUBSTRING(CONVERT(varchar(100),d_bdate, 24), 0, 9),21) from B2C_daima where d_no='B04'
select
case when Datename(hour,d_edate)> Datename(hour,d_bdate) then
convert(datetime,'2016-09-19 '+SUBSTRING(CONVERT(varchar(100),d_edate, 24), 0, 9),21)
else
convert(datetime,'2016-09-18 '+SUBSTRING(CONVERT(varchar(100),d_edate, 24), 0, 9),21) end
from B2C_daima where d_no='B04'
select DateAdd(MINUTE,DATEDIFF(MINUTE,t.shangban,t.xiaban)/2 ,t.shangban) as middletime from ( select convert(datetime,'2016-09-18 '+SUBSTRING(CONVERT(varchar(100),d_bdate, 24), 0, 9),21) as shangban,case when Datename(hour,d_edate)> Datename(hour,d_bdate) then
convert(datetime,'2016-09-19 '+SUBSTRING(CONVERT(varchar(100),d_edate, 24), 0, 9),21)
else
convert(datetime,'2016-09-18 '+SUBSTRING(CONVERT(varchar(100),d_edate, 24), 0, 9),21) end as xiaban from B2C_daima where d_no='B04' ) t