码迷,mamicode.com
首页 > 其他好文 > 详细

拼字符串成为时间,和两个计算时间点的中间值

时间:2016-09-19 19:34:30      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

拼字符串成为时间,和两个计算时间点的中间值

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

拼字符串成为时间,和两个计算时间点的中间值

标签:

原文地址:http://www.cnblogs.com/sulong/p/5886202.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!