Check if date is between a period

1

In my table, I have two columns, DT_INICIO and DT_FIM , it would be an Absence table.

Let's say that an employee is absent in DT_INICIO From (25/03/2016) to DT_FIM (3/27/2016), I need to make an appointment on 03/26/2016, as I verify if that date is between Start and End?

Thank you.

    
asked by anonymous 31.03.2016 / 20:14

1 answer

3

You can use between it specifies a range of be tested.

Syntax:

test_expression [ NOT ] BETWEEN begin_expression AND end_expression

Arguments?

test_expression

  

It is the expression to be tested in the range defined by   begin_expressione end_expression. test_expression must have the same   data type that begin_expression and end_expression.

NOT

  

Specifies that the predicate result should be denied.

begin_expression

  

Is any valid expression. begin_expression must have the same type of   data that test_expression and end_expression.

end_expression

  

Is any valid expression. end_expression must have the same type of   data to test_express begin_expression.

AND

  

Acts as a placeholder that indicates that test_expression should   be within the range indicated by begin_expression and   end_expression.

In short.

Select * from sua tabela
where suadata BETWEEN DT_INICIO and DT_FIM
    
31.03.2016 / 20:26