For example 2 coloums start and finish
2 dates
start = 2010-05-23
finish = 2010-07-26
I want to get all days like 2010-05-23,2010-05-24 etc.
can I do it with mysql or should I use php
thank you.
For example 2 coloums start and finish
2 dates
start = 2010-05-23
finish = 2010-07-26
I want to get all days like 2010-05-23,2010-05-24 etc.
can I do it with mysql or should I use php
thank you.
You want to generate all dates between a start and end point stored in a database, not find all rows between two dates, right?
I think doing that in your programming language would be more appropriate.
$sql = "SELECT start, finish FROM sometable";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
for ($i = strtotime($row['start']); $i <= strtotime($row['finish']); $i += 24*60*60) {
echo date('Y-m-d', $i) . "<br />";
}
thank you but. this that calculate months with 30,31 or for example february 28 or 29?
Yes.
It is adding 24 hours at a time to a UNIX timestamp beginning at your start date and ending on your finish date.
date() converts the timestamp to a formatted string and handles all the calculations.
thank you again