Psyche
Psyche

Reputation: 8773

PostgreSQL type casting issue

I have imported a PostgreSQL database and I keep getting this error:

ERROR: operator does not exist: date >= integer LINE 1: ...tut.id_pf AND evidenta_info_statut.data_sch_statut>=2010-07-... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

My query looks like this:

SELECT p_fiz.nr_certif, p_fiz.nume, p_fiz.prenume, localizari.id_jud, evidenta_info_statut.data_sch_statut,evidenta_info_statut.statut, rapoarte_anuale.data_depunere,rapoarte_anuale.angajamente, evidenta_asigurari.data_end,lista_statute.descriere, localizari.id_jud, p_fiz.nume, p_fiz.prenume, p_fiz.nr_certif,p_fiz.id_pf,p_fiz.nume,p_fiz.prenume,p_fiz.codificare from p_fiz INNER JOIN localizari USING (id_loc) INNER JOIN evidenta_contacte USING (id_contact) LEFT JOIN lista_statute USING (id_statut_existenta) LEFT JOIN evidenta_info_statut ON p_fiz.id_pf=evidenta_info_statut.id_pf AND evidenta_info_statut.data_sch_statut>=2010-07-12 LEFT JOIN rapoarte_anuale ON p_fiz.id_pf=rapoarte_anuale.id_pf AND rapoarte_anuale.an > 2010 LEFT JOIN evidenta_asigurari ON p_fiz.id_pf=evidenta_asigurari.id_pf AND evidenta_asigurari.data_start >= 2010-07-12 ORDER BY localizari.id_jud ASC, p_fiz.nume ASC, p_fiz.prenume ASC, p_fiz.nr_certif ASC;

As I understand it, it's those >= or > causing the eror.

Any ideea how to fix this?

P.S. I'm running PostgreSQL 8.4 on Fedora.

Upvotes: 1

Views: 675

Answers (2)

Clodoaldo Neto
Clodoaldo Neto

Reputation: 125244

Wrap the date in quotes

'2010-07-12'

Upvotes: 0

Frank Farmer
Frank Farmer

Reputation: 39356

You need to quote your dates.

evidenta_info_statut.data_sch_statut >= '2010-07-12'
evidenta_asigurari.data_start >= '2010-07-12'

Without quotes, those are actually evaulated as integer math; 2010 - 7 - 12 = 1991

Upvotes: 2

Related Questions