I have a database table build in this structure.
ID - INT
addDate - DateTime
sunrise - Time
sunset - Time
Now I'm trying to retrieve the difference in minutes between
SELECT addDate, TIMESTAMPDIFF(MINUTE, sunrise, sunset) AS duration FROM SunData WHERE date(addDate) BETWEEN curdate() - interval 7 day and curdate() ORDER BY addDate ASC
The results I'm getting NULL in every row for duration.
Code to display these values
$date = date("Y-m-d H:i:s", strtotime(str_replace('-','/',$row->addDate)));
$duration = $row->duration / 60;
echo "Dauer: " . $duration . "Stunden
";
Why are the values getting less and less? Is my query correct?