dr_rk
dr_rk

Reputation: 4565

MySQL phpMyAdmin error in a simple date query

In MySQL using phpMyAdmin I am trying out this simple query to fetch rows that satisfy a certain date criteria:

select * 
from student_invoice
where date_generated < '2012-01-01'

The date_generated is of date type. I get an error in phpMyAdmin that says:

ERROR: Unclosed quote @ 64 STR: '

I have closed all quotes so its not making sense. The phpMyAdmin version is 2.11.9.6

Upvotes: 1

Views: 2112

Answers (4)

Gsinti
Gsinti

Reputation: 124

Adding a new answer, as it's unrelated to my other one.

According to this bugzilla post here, your version suffers from this bug!

Upgrading to 2.11.11 or higher should fix this issue.

Upvotes: 2

Gsinti
Gsinti

Reputation: 124

This may sound silly, but have you tried wrapping the date in double quotes?

SELECT * 
FROM sometable
WHERE somedatecolumn < "2012-01-01"

Upvotes: 1

eatonphil
eatonphil

Reputation: 13692

Not familiar with the specific error. But you could try casting your static date to a date format, just to make sure it jives with the datecolumn format. Or even casting both? I.e:

  where cast(somedatecolumn as DATE) < cast('2012-01-01' as DATE)

I have a feeling that won't work though. So maybe this?:

  where somedatecolumn < cast('2012-01-01' as DATE)

Upvotes: 0

Asaph
Asaph

Reputation: 162821

Make sure that those are actually single quotes surrounding the date, not backticks.

Upvotes: 0

Related Questions