How to select the dates between two dates in mysql?

by raven_corwin , in category: MySQL , a year ago

How to select the dates between two dates in mysql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by ryan.murray , a year ago

@raven_corwin 

To select the dates between two dates in MySQL, you can use the BETWEEN operator along with the >= (greater than or equal to) and <= (less than or equal to) operators. Here's an example:

1
2
3
SELECT *
FROM your_table
WHERE date_column BETWEEN 'start_date' AND 'end_date';


Replace your_table with the name of your table and date_column with the name of the column that contains the dates.


Replace 'start_date' and 'end_date' with the actual start and end dates you want to retrieve the data between. Make sure the dates are in the proper format accepted by MySQL (e.g., 'YYYY-MM-DD').


Note that the BETWEEN operator is inclusive, so it will include both the start and end dates in the result set.

Related Threads:

How to compare two dates in moment.js?
How to compare the seconds between two dates to an integer in oracle?
How to get the data between two dates and times in laravel?
How to check if two dates are more than 7 days apart using moment.js?
How to get weeks array within two dates with moment.js?
How to get days between two dates using sparql?