Query de evento transação entre periodo start e end Datas SQL

28 de setembro de 2017   |   by administrador
DECLARE
@dtt_start datetime,
@dtt_end datetime,
@dtt_transacao datetime

set @dtt_start = '2017-09-29 16:00:00';
set @dtt_end = '2017-09-30 17:00:00';

set @dtt_transacao = '2017-09-30 15:00:00';

create table #temp(
dtt_start datetime,
dtt_end datetime)

--select @dtt_start,@dtt_end
insert into #temp(dtt_start,dtt_end)values(@dtt_start,@dtt_end)

select 'esta dentro do range'
from #temp
where dtt_start <= @dtt_transacao and dtt_end >= @dtt_transacao

drop table #temp
Tags: