$query= "SELECT * FROM debtors WHERE DATE_FORMAT(DueDate,'%Y-%m-%d') < CURDATE()";
This is the sql query I use to fetch the dates which have passed today's date.
$query= "SELECT * FROM debtors WHERE DATE_FORMAT(DueDate,'%Y-%m-%d') < CURDATE()";
This is the sql query I use to fetch the dates which have passed today's date.
$query=SELECT *,DATEDIFF(mm,YOUR_DATE,CURRENT_TIMESTAMP) as diffInMonth FROM debator;
May be helpful to you.It works in MS SQL 2012 for me. DATEDIFF(interval,start_date,end_date);
Here's how to get the difference, based on your query. using datediff
$query= "SELECT *, datediff(curdate(), DueDate) FROM debtors WHERE DATE_FORMAT(DueDate,'%Y-%m-%d') < CURDATE()";
Please try with this one:
$query= "SELECT *, DATEDIFF(CURDATE(), STR_TO_DATE(DueDate, '%Y-%m-%d')) AS days FROM debtors WHERE DATE_FORMAT(DueDate,'%Y-%m-%d') < CURDATE()";