PostgreSQL TO_DATE query issue

12,199

You have:

to_date('12 Feb 2007', 'YYYY-MM-DD')

instead of:

to_date('12 Feb 2007', 'DD Mon YYYY')

So you're trying to parse date using wrong format. See the reference.

Share:
12,199
Psyche
Author by

Psyche

Updated on June 17, 2022

Comments

  • Psyche
    Psyche almost 2 years

    I have the following PostgreSQL query:

    INSERT INTO persoane_alocate(pa_id_pj,pa_id_corespondent_persoana,pa_procentaj,pa_tip_persoana,pa_data_inceput,pa_data_sfarsit,pa_afisare_in_monitor,audit_data_modificarii,audit_id_utilizator) VALUES ('670', '534', '0', '1', CASE 0000-00-00 WHEN 0 THEN NULL ELSE TO_DATE('30 Nov -0001', 'YYYY-MM-DD') END, CASE 2007-02-12 WHEN 0 THEN NULL ELSE TO_DATE('12 Feb 2007', 'YYYY-MM-DD') END, '2', '2012-03-20 17:11:34', 9999)
    

    And I get the following error:

    Query failed: ERROR: invalid value "Fe" for "MM" DETAIL: Value must be an integer.
    

    Any ideas about how to fix it?

    Thanks.