1

Topic:

Hello! Prompt that I do not so.
There is a table
__________________________________
--Cat No---- StartData------ StopData-------
------------------------------------------------
--9---- 7/3/2018 - 8/3/2018 - -
--10---- 8/4/2018 - 9/4/2018 - -
==========================
It is impossible to make sampling by date

$SystemData = 7/11/2018
$query = "SELECT * FROM Catalog_List WHERE DATE_FORMAT (StartDate, ' %Y- % M - % d ')> = '". $SystemData. "' AND DATE_FORMAT (StartDate, ' %Y- % M - % d ') <= '". $SystemData. "'";

2

Re:

I will simply leave it here  

3

Re:

$query = "SELECT * FROM Catalog_List WHERE DATE (StartDate) BETWEEN ' 7/2/2018 ' AND ' 7/2/2018 '";

And in the answer the white screen
[mergetime] 1530607024 [/mergetime]

$query = "SELECT * FROM Catalog_List WHERE DATE (StartDate) BETWEEN ' 2018-07-03 ' AND ' 2018-07-09 '";

The white screen (data output is not present)

4

Re:

And here so produces the data

$query = "SELECT * FROM Catalog_List WHERE DATE_FORMAT (StartDate, ' %Y- % M - % d ')> = '". $SystemData. "' OR DATE_FORMAT (StopDate, ' %Y- % M - % d ') <= '". $SystemData. "'";

And at AND is not present

$query = "SELECT * FROM Catalog_List WHERE DATE_FORMAT (StartDate, ' %Y- % M - % d ')> = '". $SystemData. "' AND DATE_FORMAT (StopDate, ' %Y- % M - % d ') <= '". $SystemData. "'";

5

Re:

And for whom a condition? Also is after all BETWEEN.

6

Re:

I in php  and as it to use if dates from two columns Start and Stop

7

Re:

If in two and the first, this minimum value, and the second maximum WHERE StartDate> = value AND StopDate <= value, and formatting of dates any it is not required. Here only as it is possible to receive a range of mines/maks if the parameter at both is equal to the same value $SystemData, or . Can be less than minute, or on the contrary?

8

Re:

$query = "SELECT * FROM Catalog_List WHERE StartDate> = ' 2018-07-05 ' AND StopDate <= ' 2018-07-06 '";

There is no data

$query = "SELECT * FROM Catalog_List WHERE StartDate> = 2018-07-05 AND StopDate <= 2018-07-06";

Too there is no data

9

Re:

--
-- Table structure ` tmp`
--
CREATE TABLE ` tmp ` (
` id ` int (11) UNSIGNED NOT NULL;
` StartDate ` date NOT NULL;
` StopDate ` date NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
--  the table data ` tmp`
--
INSERT INTO ` tmp ` (` id `, ` StartDate `, ` StopDate `) VALUES
(1, ' 2018-05-01 ', ' 2018-07-03 ');
(2, ' 2018-04-03 ', ' 2018-07-03 ');
(3, ' 2018-06-13 ', ' 2018-07-03 ');
--
-- Indexes of the saved tables
--
--
-- Table indexes ` tmp`
--
ALTER TABLE ` tmp`
ADD PRIMARY KEY (` id `);
--
-- AUTO_INCREMENT For the saved tables
--

Request ' SELECT * FROM tmp WHERE StartDate> = "2018-05-01" AND StopDate <= "2018-07-03"'
Result

Array
(
[0] =>
(
[id] => 1
[startdate] => 2018-05-01
[stopdate] => 2018-07-03
)
[1] =>
(
[id] => 3
[startdate] => 2018-06-13
[stopdate] => 2018-07-03
)
)

10

Re:

Here so works If StartDate in basis equally 2018-07-03 and StopDate it is equal 2018-07-12

$query = "SELECT * FROM Catalog_List WHERE StartDate> = ' [b] 2018-07-03 [/b] ' OR StopDate <= ' [b] 2018-07-12 [/b] '";

And so is not present

$query = "SELECT * FROM Catalog_List WHERE StartDate> = ' 2018-07-04 ' OR StopDate <= ' 2018-07-04 '";

[mergetime] 1530622904 [/mergetime]
Forgive not OR and AND
[mergetime] 1530623197 [/mergetime]
All MANY THANKS!!! Found an error!