Today, I had a issue in $wpdb.
I used
$result = $wpdb->get_var(
$wpdb->prepare(
"SELECT DATE_FORMAT(report_date, '%d-%m-%Y') FROM table WHERE report_id = %d",
$report_id
)
);
The above code not works because of %d in mysql DATE_FORMAT
.
How i solved this issue in wordpress.
Try this:
$result = $wpdb->get_var(
$wpdb->prepare(
"SELECT DATE_FORMAT(report_date, '%%d-%%m-%%Y') FROM table WHERE report_id = %d",
$report_id
)
);
You need to escape the %
's by using %%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With