There is a news base with fields:

 | id | title | batetime -------------------------------------- | 1 | блаблабла | 2014-03-14 10:35:20 

It is necessary to display, for example, all the news that are between the dates 2014-03-10 and 2014-03-20

How to make a MySql request?

Tried, it turns out a complete heresy ...

  • What have you tried? Give an example of a non-working request. - Ivan Solntsev
  • mysql_query ("SELECT * FROM news WHERE datetime> = '. $ date_go.' and datetime <= '. $ date_to.'"); - Alexander Sizintsev
  • And what was the error message? In which format were the values ​​$ date_go and $ date_to? At least in the given query, the quotes are missing from the strings in the query. - Ivan Solntsev

1 answer 1

BETWEEN operator

 SELECT * FROM news WHERE batetime BETWEEN '2014-03-10' AND '2014-03-20' 
  • heartfelt thanks! - Alexander Sizintsev