Page 1 of 1
picking dates between two dates.
Posted: Mon Feb 26, 2007 3:35 am
by itsmani1
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
Posted: Mon Feb 26, 2007 4:16 am
by onion2k
Very basically, and if you're working with a single date column in the database...
Code: Select all
select * from myTable where myDateColumn >= '2000-03-03 00:00:00' and myDateColumn <= '2000-04-04 00:00:00'
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).
Posted: Mon Feb 26, 2007 10:32 am
by pickle
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'