I have a mysql table named payment and there is a field in it called next_due_date which holds a manually entered date value from the user in yyyy-mm-dd format and the type is VARCHAR. I tried
select * from payment where next_due_date >= '$strtdate' AND next_due_date <= '$endDate';
$strtdate holds current date and $endDate holds the date value before 30 days from the current date.
Logic issues – you are asking for records where the next_due_date is AFTER today AND where the next_due_date is BEFORE 30 days ago. Think about that and you’ll see why you get no records 🙂
You probably want something more like:
Although that still looks ‘weird’ – probably because instead of:
“$strtdate holds current date and $endDate holds the date value before 30 days from the current date.”
Perhaps you want:
$strtdate holds 30 days before now and $endDate holds the current date.
THEN you can have:
from payment where next_due_date >= ‘$strtdate’ AND next_due_date <= ‘$endDate’;