ho creato una funzione nel database che restituisce 0 o 1
che richiamo nella query in questo modo
Codice:
dbo.summertime(iv_year, iv_month, iv_day) as SummerTime
Codice:
create function SummerTime(@Year int, @Month int, @Day int)
returns int
as
begin
declare @SummerTime int, @aa int, @bb int, @cc int, @STBeg_y int, @STBeg_m int, @STBeg_d int, @STEnd_y int, @STEnd_m int, @STEnd_d int
set @aa = -CEILING(-5*@Year/4)
set @bb = @aa+4
set @cc = @aa+1
set @STBeg_y = @Year
set @STBeg_m = 3
set @STBeg_d = 31-(@bb+7*CEILING(-@bb/7))
set @STEnd_y = @Year
set @STEnd_m = 10
set @STEnd_d = 31-(@cc+7*CEILING(-@cc/7))
set @SummerTime = CASE WHEN
dbo.date(@Year, @Month, @Day) >= dbo.date(@STBeg_y, @STBeg_m, @STBeg_d) and
dbo.date(@Year, @Month, @Day) < dbo.date(@STEnd_y, @STEnd_m, @STEnd_d) then 1 else 0 end
return @SummerTime
end
go
penso ti sarà facile tradurla in ogni altro linguaggio,
i parametri necessari sono anno, mese e giorno
ciao
Marino