create function [dbo].[dhp](@stcd varchar(10),@d1 varchar(100) )-- stcd 表示站点编号 d1表示时间
returns decimal
as
begin
declare @dhp decimal
if (datename(hour,@d1)>'8')
select @dhp= sum(drp) from st_pptn_r where stcd=@stcd and tm between @d1
and convert(varchar(100),year(dateadd(day,1,@d1)))
+'-'+convert(varchar(100),month(dateadd(day,1,@d1)))
+'-'+convert(varchar(100),day(dateadd(day,1,@d1)))
+' 8:00:00'
else
select @dhp= sum(drp) from st_pptn_r where stcd=@stcd
and tm between convert(varchar(100),year(dateadd(day,-1,@d1)))
+'-'+convert(varchar(100),month(dateadd(day,-1,@d1)))
+'-'+convert(varchar(100),day(dateadd(day,-1,@d1)))
+' 9:00:00' and @d1
return @dhp
end
桃花长相依
相关分类