R
R
Roman2015-05-17 14:59:28
PHP
Roman, 2015-05-17 14:59:28

How to write a request with BETWEEN?

The database has 2 fields with dates. The from and to fields contain dates from and to , such as 20150517 and 20150520 .
I send two dates in the form, and those users who enter the specified period are shown.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2015-05-17
@emtecif

Already figured out, you can delete the question), and if not, maybe someone will come in handy.

SELECT * FROM student WHERE DATE(from_date) >= '2015-05-01' AND DATE(to_date) <= '2015-05-23'

M
Mykola, 2015-05-17
@iSensetivity

SELECT * FROM `student` WHERE (from_date BETWEEN '2015-05-01' AND '2015-05-23') AND (to_date BETWEEN '2015-05-01' AND '2015-05-23');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question