PHP and MySQL BETWEEN dates with different years

PHP and MySQL BETWEEN dates with different years

I have a database which holds a bunch of events. Each event has a start date and an end date, so they should only show on the site when the date chosen falls between those dates.

I thought it made sense to make use of the SQL BETWEEN statement, but it does not work.

When a user chooses a year and month, I assign php vars and run the query.

Here's the query:

SELECT * FROM table WHERE $year BETWEEN YEAR(Start) AND YEAR(End) AND $month BETWEEN MONTH(Start) AND MONTH(End)

Any ideas or suggestions how to do this?

View Answers









Related Tutorials/Questions & Answers:
PHP and MySQL BETWEEN dates with different years
PHP and MySQL BETWEEN dates with different years  I have a database... they should only show on the site when the date chosen falls between those dates. I thought it made sense to make use of the SQL BETWEEN statement, but it does
mysql between dates not between dates
mysql between dates not between dates  I am trying to list the data between dates and not between dates using join method ..but that not working for me
Advertisements
How to select Data Between Two dates in Java, MySQL
How to select Data Between Two dates in Java, MySQL  How to select Data Between Two dates in Java, MySQL? Thanks in advance.   http://www.v7n.com/forums/coding-forum/294668-how-select-data-between-two-dates-php
days between two given dates using PHP
days between two given dates using PHP  How can we know the number of days between two given dates using PHP?   Hi friends, Example... dates. </title> </head> <body> <?php
How can we know the number of days between two given dates using PHP?
How can we know the number of days between two given dates using PHP?  How can we know the number of days between two given dates using PHP
range of dates in mysql query
range of dates in mysql query  How to select the range of dates in mysql ..when i have to select from between & and of date function?   SELECT * FROM MAAccounts WHERE updatedOn BETWEEN ? AND ? ORDER
display dates between two dates - Java Beginners
display dates between two dates  hi can any one help me to writing this code, i need to store the dates between to dates so that i can retrive the data from the db using theses dates. its urgent pls tell me as possible
calculate difference between two dates
calculate difference between two dates  hi, I was actually working on to calculate the number of days between two dates of dd/mm/yyyy format... the difference between the two dates
Different between getRequestParameterMap() and getRequestParameterValuesMap()
Different between getRequestParameterMap() and getRequestParameterValuesMap()  What is the different between getRequestParameterMap() and getRequestParameterValuesMap
MySql PHP Connection String - PHP
MySql PHP Connection String  i need a MySql PHP Connection String, is it possible to do pooling in between
different between ntfs and fat
different between ntfs and fat   hello, what is the different between ntfs and fat ???   hello,ADS_TO_REPLACE_1 The major difference between FAT and NTFS is security. If you have FAT partition then Security and Quota
How to use between in mysql.
How to use between in mysql.  I want to display records inbetween two dates and also want to use where condition( like and deptname='Pediatry... WHERE column_name BETWEEN value1 AND value2 Here is an example, we have a table
PHP Mysql Group By
PHP Mysql Group By       PHP Mysql Group By is used to establish a relation between the PHP..._TO_REPLACE_1 The Tutorial illustrate an example from PHP Mysql Group By. To understand
PHP Mysql Database Connection
PHP Mysql Database Connection       PHP Mysql Database Connection is used to build a connection between the PHP on the server-side and Mysql on the backend. Understand
Listing out leap years between certain period
Listing out leap years between certain period  ... the coding for finding and listing out the leap years between two years. In the following example we have to find out the leap years between 1990 and 2006. First
list of all months between two dates in java
list of all months between two dates in java  Hi, I want to get list of all months with year between two dates. How to do this in Java? Thanks   Hi, This is the example code which can be used: package test.app
list of all months between two dates in java
list of all months between two dates in java  Hi, I want to get list of all months with year between two dates. How to do this in Java? Thanks   Hi, This is the example code which can be used: package test.app
JavaScript check if date is between two dates.
JavaScript check if date is between two dates.  Check if date is between two dates?   <html> <head> <title>Date before... it is lying between dates or not.Date.parse() is used to convert
php mysql
php mysql  automatically insert a value in the month field at the last date of current month in mysql database
php mysql
php mysql  automatically insert a value in the month field at the last date of current month in mysql database
Hi .Difference between two Dates - Java Beginners
Hi .Difference between two Dates  Hi Friend.... Thanks for ur Very good response.. Can u plz guide me the following Program.... difference between two dates.. I need to display the number of days by Each Month
mysql difference between two numbers
mysql difference between two numbers  How to get total bate difference between two dates for example 1/01/2012 and 1/02/2012 in MYSQL?   ..., '01/02/2012', 103))   DATEDIFF() in MYSQL always returns the difference
Difference between Mysql and SQL
Difference between Mysql and SQL  hello, What is the difference between Mysql and SQL??   hii,ADS_TO_REPLACE_1 SQL is structural quary language but mysql is database package
to calculate the difference between two dates in java - Java Beginners
to calculate the difference between two dates in java  to write a function which calculates the difference between 2 different dates 1.The function should accept 2 different dates (in the format dd/mm/yyyy hh:mm:ss AM/PM) 2.The
why php and mysql - PHP
why php and mysql  I noticed in most of the application that developer always use mysql with PHP. Why they do so,, as there are money other database are too available
WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP?
WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP?  WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP
PHP search data with different format
PHP search data with different format  How to search data with different format in PHP
PHP Date compare the dates, PHP Compare dates example
The PHP Date compare the dates example code In this PHP Compare dates example, we are describing the code to compare the dates. In the php program we have... to compare two difference dates in PHP echo "<b>PHP Date compare
Different tables present in MySQL
Different tables present in MySQL  What are the different tables present in MySQL? Which type of table is generated when we are creating a table.... Merge 4. INNO DB 5. ISAM MyISAM is the default storage engine as of MySQL 3.23.
Upgrading databases between MySQL 5.0 to MySQL 5.5
Upgrading databases between MySQL 5.0 to MySQL 5.5  Upgrading databases between MySQL 5.0 to MySQL 5.5
Upgrading a PHP/MYSQL application?
Upgrading a PHP/MYSQL application?  Upgrading a PHP/MYSQL application
secure php mysql connection
secure php mysql connection  secure php mysql connection script
Mysql Time Difference Function
difference between any two dates. Understand with ExampleADS_TO_REPLACE_1 The Tutorial... that return you the time difference between any two consecutive dates. TimeDiff... Mysql Time Difference Function     
Javascript calculate number of days between two dates
Javascript calculate number of days between two dates In this tutorial, you will learn how to calculate number of days between two dates.For this, you need... using Date.getTime() function. Once both Dates have been converted, subtracting
PHP and MySQL Work Well Together
PHP and MySQL are open source programs that are very different from each other... and MySQL together. These can work with many different kinds of modules. These include... important for anyone to use. The first thing to know is that the PHP script can work
enum php mysql
enum php mysql  How to use mysql enum in php
PHP MYSQL Interview Questions
PHP MYSQL Interview Questions  What kind of questions can be asked in an PHP, MYSQL interview? Can anyone post the PHP interviews questions with well explained answers?   PHP, MYSQL Interview Questions Please tell me
Java get number of days between dates
Java get number of days between dates  ... the number of days between the two described dates. In order to get the number of days between two dates, the given example has set two dates by using
php form post to mysql
php form post to mysql  How to post data into mysql database from the PHP post data form
Jdbc connectivity in java to oracle for retrieving data between two dates
Jdbc connectivity in java to oracle for retrieving data between two dates  Dear Sir, I Need a program in which i want to retrieve the data b/w two dates from the database table. I am using combo box to get the date. Problem
display diffrence between two dates in a text box - JSP-Servlet
display diffrence between two dates in a text box  i have these set of codes // String di=request.getParameter("timestamp2"); String d2=request.getParameter("timestamp3"); SimpleDateFormat formater=new SimpleDateFormat("dd-mm
List out different arguments in PHP header function?
List out different arguments in PHP header function?   List out different arguments in PHP header function
ide php mysql
ide php mysql  what is ide for php and mysql   Hi, You can use Eclipse to develop your PHP project. The easist way is to download the Eclipse having PHP support from eclipse download site.ADS_TO_REPLACE_1 The Eclipse
Mysql-Php code
Mysql-Php code  I want to mysql script for query data from two tables in the mysql database trough php code. Can you help me   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 Php Mysql Thanks   
PHP MySQL query
PHP MySQL query  I have 11 tables and have to do the CRUD operations keeping userid as a reference key
php inserting date into mysql
php inserting date into mysql  php inserting date into mysql   Here is a php code that inserts date into mysql database. In the given code, data is a database table. <?php table $query_manual = "INSERT INTO data
PHP mysql database backup script - PHP
PHP mysql database backup script  How can i get the database backup using PHP mysql database
Mysql Date Comparison
Mysql Date Comparison       Mysql Date Comparison is used to return the date from a table on the basis of comparison between any two values of dates. Understand
Mysql Date in between
Mysql Date in between       The Tutorial illustrates an example Mysql date in between . In this Tutorial we illustrate an example that help you to get the date in between. Query
Mysql Date Ranges
Mysql Date Ranges       Mysql Date Ranges is useful when you want to see the records between... between the two dates specified in Where Clause from the table 'userform'. 

Ads