2

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.

1
  • 2
    What do you expect the epxression CASE 2007-02-12 WHEN 0 to do? Commented Mar 20, 2012 at 15:21

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.