I have a table named leaves.
----------
id FromDate ToDate
1 20-01-2019 22-01-2019
2 15-01-2019 22-01-2019
3 13-01-2019 20-01-2019
I want all dates between each column.
Can anyone help?
I have a table named leaves.
----------
id FromDate ToDate
1 20-01-2019 22-01-2019
2 15-01-2019 22-01-2019
3 13-01-2019 20-01-2019
I want all dates between each column.
Can anyone help?
You can try below using datediff()
function
select id, fromdate, todate,datediff(ToDate,fromdate) as days
from tablename
If you want to do it in your php code then you can do it by finding day count between two days and loop it to get the all dates between that two dates.
<?php
$date1 = "2019-01-13";
$date2 = "2019-01-20";
$date1 = strtotime("2019-01-13");
$date2 = strtotime("2019-01-20");
$datediff = $date2 - $date1;
$days = round($datediff / (60 * 60 * 24));
for($i=1;$i<=$days;$i++){
echo $date1 = date('d-m-Y', strtotime($date1 . ' +1 day'));echo ' <br> ';
}