Fórum Hora #298560
06/10/2005
0
Identificar que se a hora for ( 06:00:01 entre este período 12:00:00) e 1
Identificar que se a hora for ( 12:00:01 entre este período 18:00:00) e 2
Identificar que se a hora for ( 18:00:01 entre este período 24:00:00) e 3
Identificar que se a hora for ( 24:00:01 entre este período 06:00:00) e 4
Como que faço para calcular e identificar se esta entre estes período e daí dar um numero para identificação de períodos
Rr
Curtir tópico
+ 0Posts
06/10/2005
Bruno Belchior
Gostei + 0
06/10/2005
Bruno Belchior
function TForm1.RetornaTipo(Data: TDateTime): Shortint; var H, M, S: Byte; begin H := HourOf(Data); M := MinuteOf(Data); S := SecondOf(Data); if ((H in [6..11]) or ((H = 12) and (M = 0) and (S = 0))) and ((H = 6) and (M = 0) and (S = 0) = False) then Result := 1 else if (H in [12..17]) or ((H = 18) and (M = 0) and (S = 0)) then Result := 2 else if (H in [18..23]) or ((H = 0) and (M = 0) and (S = 0)) then Result := 3 else if (H in [0..5]) or ((H = 6) and (M = 0) and (S = 0)) then Result := 4 else Result := -1 end;
Gostei + 0
06/10/2005
Bruno Belchior
returns (Resultado Smallint)
as
declare variable H Smallint;
declare variable M Smallint;
declare variable S Smallint;
begin
select Extract(Hour from :dtData) from RDB$Database into H;
select Extract(Minute from :dtData) from RDB$Database into M;
select Extract(Second from :dtData) from RDB$Database into S;
if (((H between 6 and 11) or ((H = 12) and (M = 0) and (S = 0))) and
(not ((H = 6) and (M = 0) and (S = 0)))) then
Resultado = 1;
else if ((H between 12 and 17) or ((H = 18) and (M = 0) and (S = 0))) then
Resultado = 2;
else if ((H between 18 and 23) or ((H = 0) and (M = 0) and (S = 0))) then
Resultado = 3;
else if ((H between 0 and 5) or ((H = 6) and (M = 0) and (S = 0))) then
Resultado = 4;
else
Resultado = -1;
suspend;
end;[/code]
Gostei + 0
06/10/2005
Bruno Belchior
create procedure RetornaTipo(dtData TimeStamp) returns (Resultado Smallint) as declare variable H Smallint; declare variable M Smallint; declare variable S Smallint; begin select Extract(Hour from :dtData) from RDB$Database into H; select Extract(Minute from :dtData) from RDB$Database into M; select Extract(Second from :dtData) from RDB$Database into S; if (((H between 6 and 11) or ((H = 12) and (M = 0) and (S = 0))) and (not ((H = 6) and (M = 0) and (S = 0)))) then Resultado = 1; else if ((H between 12 and 17) or ((H = 18) and (M = 0) and (S = 0))) then Resultado = 2; else if ((H between 18 and 23) or ((H = 0) and (M = 0) and (S = 0))) then Resultado = 3; else if ((H between 0 and 5) or ((H = 6) and (M = 0) and (S = 0))) then Resultado = 4; else Resultado = -1; suspend; end;
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)