Hello,
I have a table that among other details it's store a start date and an end date. (Start date is "smaller" than end date!)
Is is possible to print out the dates that are in between start date and end date?
I am using MySQL (and i will try later to import this into php)
e.g.
Start date: 2012-01-01
End date: 2012-01-07
result
2012-01-01
2012-01-02
2012-01-03
2012-01-04
2012-01-05
2012-01-06
2012-01-07
Thanks in advance!
2 replies to this topic
#1
Posted 24 January 2012 - 06:08 PM
|
|
|
#2
Posted 25 January 2012 - 07:16 AM
I believe comparison operators (greater than and less than) work correctly with MySQL date types, with greater than being further into the future and less than being further into the past, so comparing them just like integers should work.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
#3
Posted 01 February 2012 - 06:30 PM
This is how I did it in PHP
$query4 has as a result the starting date and
$query5 the end date.
I want to thank Vaielab that help me on this one!
$query4 has as a result the starting date and
$query5 the end date.
$now = $query4;
while($now < $query5) {
echo($now . '<br />');
$now = date('Y-m-d', strtotime(date("Y-m-d", strtotime($now)) . " +1 day"));
}
I want to thank Vaielab that help me on this one!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









