i want to fetch all the dates between two dates using a MySql query.
my start date is : 2000-03-03 00:00:00
my end date is : 2000-04-04 00:00:00
and i want to pick all the dates between these two.
any way?
thank you
picking dates between two dates.
Moderator: General Moderators
Very basically, and if you're working with a single date column in the database...
If you've got 2 date columns in the database (each record having a start and end date for example) it gets a little more complicated, but it's still pretty easy. If you need code for that then say so and I'll post some.
Obviously all this stuff requires the dates in the database to be some sort of date type (date, datetime, timestamp, etc).
Code: Select all
select * from myTable where myDateColumn >= '2000-03-03 00:00:00' and myDateColumn <= '2000-04-04 00:00:00'Obviously all this stuff requires the dates in the database to be some sort of date type (date, datetime, timestamp, etc).
You could use BETWEEN syntax
Code: Select all
SELECT
*
FROM
myTable
WHERE
WHERE myDateColumn BETWEEN '2000-03-03 00:00:00' AND '2000-04-04 00:00:00'Real programmers don't comment their code. If it was hard to write, it should be hard to understand.