You can use datediff which returns the value in days from one date to the other
select datediff(day1, day2);
So,
select datediff(CURDATE(), subdate) from mytable;
문제
I need to calculate days number from subscribing date that i have in Mysql table to today, i need the number of days.
table name : mytable
date field name : subdate
I tried this but it doesn't work:
$today = CURDATE();
$subdate= ('subdate');
$days = (strtotime($today) - strtotime($subdate)) / (60 * 60 * 24);
solved thanks : my final query :
$result = mysql_query("SELECT * FROM mytable WHERE country LIKE '$country' and city LIKE '$city and (datediff(CURDATE(), age))>30");
해결책
You can use datediff which returns the value in days from one date to the other
select datediff(day1, day2);
So,
select datediff(CURDATE(), subdate) from mytable;
다른 팁
try this
$today = CURDATE();
$subdate= ('subdate');
$days = strtotime($today) - strtotime($subdate);
echo floor($days/(60*60*24));