Questions tagged [between]

The SQL BETWEEN Operator selects values within a range. The values can be numbers, text, or dates. Is possible to select values outside a range using NOT BETWEEN. The BETWEEN operator can produce different result in different databases: In some databases excludes the test values, in some others include them and in some cases includes the first test value and excludes the last one.

1363 questions
260
votes
8 answers

Does MS SQL Server's "between" include the range boundaries?

For instance can SELECT foo FROM bar WHERE foo BETWEEN 5 AND 10 select 5 and 10 or they are excluded from the range?
Lea Verou
  • 23,618
  • 9
  • 46
  • 48
207
votes
5 answers

Postgresql query between date ranges

I am trying to query my postgresql db to return results where a date is in certain month and year. In other words I would like all the values for a month-year. The only way i've been able to do it so far is like this: SELECT user_id FROM user_logs…
John
  • 6,417
  • 9
  • 27
  • 32
167
votes
11 answers

MySQL "between" clause not inclusive?

If I run a query with a between clause, it seems to exclude the ending value. For example: select * from person where dob between '2011-01-01' and '2011-01-31' This gets all results with dob from '2011-01-01' till '2011-01-30'; skipping records…
ASD
  • 4,747
  • 10
  • 36
  • 56
161
votes
10 answers

SQL : BETWEEN vs <= and >=

In SQL Server 2000 and 2005: what is the difference between these two WHERE clauses? which one I should use on which scenarios? Query 1: SELECT EventId, EventName FROM EventMaster WHERE EventDate BETWEEN '10/15/2009' AND '10/18/2009' Query…
Shyju
  • 214,206
  • 104
  • 411
  • 497
158
votes
30 answers

generate days from date range

I would like to run a query like select ... as days where `date` is between '2010-01-20' and '2010-01-24' And return data like: days ---------- 2010-01-20 2010-01-21 2010-01-22 2010-01-23 2010-01-24
Pentium10
  • 204,586
  • 122
  • 423
  • 502
68
votes
4 answers

Select entries between dates in doctrine 2

I will go insane with this minimal error that I'm not getting fix. I want to select entries between two days, the examples below ilustrate all my fails: opt 1. $qb->where('e.fecha > ' . $monday->format('Y-m-d')); $qb->andWhere('e.fecha < ' .…
manix
  • 14,537
  • 11
  • 70
  • 107
54
votes
4 answers

What's mysql's "BETWEEN" performance over..?

Is there any better performance when querying in (particularly) mysql of the following: SELECT * FROM `table` WHERE `unix_date` BETWEEN 1291736700 AND 1291737300 over: SELECT * FROM `table` WHERE `unix_date` >= 1291736700 AND `unix_date` <=…
Darkhan
  • 1,258
  • 2
  • 13
  • 21
54
votes
4 answers

Check if current date is between two dates Oracle SQL

I would like to select 1 if current date falls between 2 dates through Oracle SQL. I wrote an SQL after reading through other…
Avinesh Kumar
  • 1,389
  • 2
  • 17
  • 26
45
votes
9 answers

PHP: How can I determine if a variable has a value that is between two distinct constant values?

How can I determine using PHP code that, for example, I have a variable that has a value between 1 and 10, or between 20 and 40?
Gabriel Meono
  • 990
  • 3
  • 18
  • 48
44
votes
7 answers

Mysql: Select all data between two dates

I have a mysql table with data connected to dates. Each row has data and a date, like this: 2009-06-25 75 2009-07-01 100 2009-07-02 120 I have a mysql query that select all data between two dates. This is the query: SELECT data FROM tbl…
Martymart
42
votes
2 answers

Filtering dates in dplyr

My tbl_df: > p2p_dt_SKILL_A%>% + select(Patch,Date,Prod_DL)%>% + head() Patch Date Prod_DL 1 P1 2015-09-04 3.43 2 P11 2015-09-11 3.49 3 P12 2015-09-18 3.45 ... 4 P13 2015-12-06 3.57 5 P14…
Shery
  • 1,808
  • 5
  • 27
  • 51
33
votes
2 answers

css difference between background: and background-image:

quick simple question In the following example of an external CSS page; body { background-image: url(background.jpg); } header { background: url(background.jpg); } I understand they are effecting different element selectors, my question is…
epicT
  • 353
  • 1
  • 3
  • 6
32
votes
4 answers

How to put space between switch button and its text in android?

I have the following element: But on designer the switch button and its text "Data about client?" are very glued together. I tried putting space between ? and " like…
Profile2ForStack
  • 473
  • 2
  • 8
  • 16
29
votes
8 answers

SQL Query Where Date = Today Minus 7 Days

I have a SQL table of hits to my website called ExternalHits. I track the URL as URLx and the date the page was accessed as Datex. I run this query every week to get the count of total hits from the week before, and every week I have to manually…
Ashley K
  • 403
  • 1
  • 6
  • 16
28
votes
3 answers

pyspark's "between" function: range search on timestamps is not inclusive

pyspark's 'between' function is not inclusive for timestamp input. For example, if we want all rows between two dates, say, '2017-04-13' and '2017-04-14', then it performs an "exclusive" search when the dates are passed as strings. i.e., it omits…
Vinay Kolar
  • 913
  • 1
  • 7
  • 13
1
2 3
90 91