T-sql BETWEEN clause

Does anyone know of a range of offer comparisons BETWEEN? if I have a data type datetime, does the sentence conclude BETWEENup to an hour / minute / second level?

+3
source share
4 answers

yes, if it is the same (up to the millisecond), then it really will say true. So it will be shown

+5
source

It:

WHERE datetime_column BETWEEN '2010-08-11' AND '2010-08-12'

equivalently

WHERE (datetime_column >= '2010-08-11 00:00:00.000' AND datetime_column <= '2010-08-12 00:00:00.000')

There are two things here:

  • , datetime. datetime , 3 4 , . , '2010-08-11', , .
  • - , IMO datetime. , , , , .
+4

. BETWEEN TRUE, test_expression begin_expression end_expression ().

:

BETWEEN date_field '2010-01-01 12:00:00' AND '2010-02-01 12:00:00'

:

date_field >= '2010-01-01 12:00:00' AND date_field <= '2010-02-01 12:00:00'
+2

Speaking val BETWEEN @lowVal AND @highValexactly the same as saying @lowVal <= val AND val <= @highVal, so yes ... a datetime comparison includes all parts of a date. See here.

+1
source

Source: https://habr.com/ru/post/1759247/


All Articles