-4

I have a mysql record with the columns start_date and end_date. Now I have a date (as example 2017-08-03) and i want to ask if this date is between the start_date and end_date in my mysql table.

Is this possible?

6
  • select * from tab where start_date<='2017-08-03' and end_Date>='2017-08-03' Commented Aug 3, 2017 at 9:27
  • You can use WHERE date BETWEEN start_date AND end_date. stackoverflow.com/questions/1080207/… Commented Aug 3, 2017 at 9:28
  • SELECT * FROM objects WHERE (date BETWEEN start_date_field AND end_date_field) Commented Aug 3, 2017 at 9:29
  • 3
    Possible duplicate of Mysql: Select all data between two dates Commented Aug 3, 2017 at 9:29
  • Instead of naively asking “is this possible”, next time please just type your question title into Google ... And please go read How to Ask - among other things, it explains to you what minimal effort you are expected to make before asking here. Commented Aug 3, 2017 at 9:33

3 Answers 3

5

Use between:

SELECT * FROM events 
  WHERE '2012-01-18' between start_date AND end_date

BTW: Take care of time part if start and end are datetime types

Sign up to request clarification or add additional context in comments.

Comments

1

You can use this:

SELECT * FROM events 
  WHERE start_date<='2012-01-18'
  AND end_date>='2012-01-18'

Comments

1
SELECT *
FROM `yourtable`
WHERE (your_found_date BETWEEN 'start_date' AND 'end_date')

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.