MyException - 我的异常网
当前位置:我的异常网» Sql Server » 哪位帮小弟我看一下,分不多

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

www.myexceptions.net  网友分享于:2013-04-10  浏览: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)

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有