当前位置: 代码迷 >> Sql Server >> 哪位帮小弟我看一下,分不多
  详细解决方案

哪位帮小弟我看一下,分不多

热度:77   发布时间:2016-04-24 23:06:23.0
哪位帮我看一下,分不多
update kq_yjg set cq=
case
  when k3104=null OR k3106=null then 0
  when  k3104<=convert(datetime,convert(varchar(100),k3103,24)+' 07:00:00') then
     case
        when k3106<=convert(datetime,convert(varchar(100),k3103,24)+' 07:00:00') then 0
        when k3106>=convert(datetime,convert(varchar(100),k3103,24)+' 07:00:00') and k3106<=convert(datetime,convert(varchar(100),k3103,24)+' 15:00:00')
          then DATEDIFF(MINUTE,convert(datetime,convert(varchar(100),k3103,24)+' 07:00:00'),k3106)/60.0
        when k3106>convert(datetime,convert(varchar(100),k3103,24)+' 15:00:00') then 8.0
     end
  when k3104>convert(datetime,convert(varchar(100),k3103,24)+' 07:00:00') and k3104<=convert(datetime,convert(varchar(100),k3103,24)+' 15:00:00') then
     case
       when k3106<=convert(datetime,convert(varchar(100),k3103,24)+' 15:00:00') then DATEDIFF(MINUTE,k3104,k3106)/60.0
       when k3106>convert(datetime,convert(varchar(100),k3103,24)+' 15:00:00') then DATEDIFF(MINUTE,k3104,convert(datetime,convert(varchar(100),k3103,24)+' 15:00:00'))/60.0
     end
when k3104>convert(datetime,convert(varchar(100),k3103,24)+' 15:00:00') then 0
end

------解决方案--------------------

convert(varchar(100),k3103,24)
=>
convert(varchar(10),k3103,120)
  相关解决方案