Reputation: 137
I am trying to have 2 where clause. The SQL statement works before I put
AND fborders.date="+todayDate);
So is there a error at my sql statement because it does not work?
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = new Date();
String todayDate = dateFormat.format(date);
("
SELECT Id,Name,quantity,date,time,
FROM orders
WHERE status='pending'
AND date="+todayDate
);
Upvotes: 0
Views: 126
Reputation: 35018
Strictly speaking you don't have to pass todays date as a parameter at all.
Assuming that your DATE
column is a DATE
type, you could just use:
SELECT Id,Name,quantity,date,time
FROM orders
WHERE status='pending'
AND date=current_date()
or is DATE
is a VARCHAR
column:
SELECT Id,Name,quantity,date,time
FROM orders
WHERE status='pending'
AND date=date_format(current_date(), '%d/%m/%Y')
Upvotes: 1
Reputation: 2318
The date needs to be in quotes too. Change it to this:
AND date='" + todayDate + "'"
Upvotes: 3
Reputation: 17194
You missed single quote sign. Date
needs quotes around that.
Here you go:
AND fborders.date='" + todayDate + "'"
Upvotes: 4