I have a form that contains optional DATE fields. To enter null
values, I've tried null, 'null', '', '-', '0', 0, and each time I get
one of the following errors:

ERROR: Bad numeric input format ''

ERROR: Bad date external representation ''

Is there a correct way to enter null values into DATE fields?

Thanks,
Jeff Deroshia

Search Discussions

  • Jeff Deroshia at Feb 18, 2003 at 9:14 pm
    I have a form that contains optional DATE fields. To enter null
    values, I've tried null, 'null', '', '-', '0', 0, and each time I get
    one of the following errors:

    ERROR: Bad numeric input format ''

    ERROR: Bad date external representation ''

    Is there a correct way to enter null values into DATE fields?

    Thanks,
    Jeff Deroshia
  • Keith Keller at Feb 18, 2003 at 11:19 pm

    On Tue, Feb 18, 2003 at 04:13:59PM -0500, Jeff Deroshia wrote:
    I have a form that contains optional DATE fields. To enter null
    values, I've tried null, 'null', '', '-', '0', 0, and each time I get
    one of the following errors:

    ERROR: Bad numeric input format ''

    ERROR: Bad date external representation ''

    Is there a correct way to enter null values into DATE fields?
    Yes:

    => create table dummy (mydate date);
    CREATE
    => insert into dummy values (null);
    INSERT 3397454 1
    => select * from dummy;
    mydate
    --------

    (1 row)

    You say you tried null: what was your insert? What's the table look
    like?

    --keith
  • Josh Berkus at Feb 19, 2003 at 12:25 am
    Jeff,
    I have a form that contains optional DATE fields. To enter null
    values, I've tried null, 'null', '', '-', '0', 0, and each time I get
    one of the following errors:
    NULL is correct, no quotes. Please post the actual insert statement
    you are sending; likely the problem is elsewhere.

    -Josh
  • Jeff Deroshia at Feb 19, 2003 at 9:03 pm
    Thanks to everyone who helped. I was using prepared statements with
    java.sql.
    I was using the setString() method to set the value to null, when I
    needed to be using the setNull() method. It created the null values
    that I needed.

    Jeff
    On Tuesday, February 18, 2003, at 07:25 PM, Josh Berkus wrote:

    Jeff,
    I have a form that contains optional DATE fields. To enter null
    values, I've tried null, 'null', '', '-', '0', 0, and each time I get
    one of the following errors:
    NULL is correct, no quotes. Please post the actual insert statement
    you are sending; likely the problem is elsewhere.

    -Josh

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedFeb 18, '03 at 8:01p
activeFeb 19, '03 at 9:03p
posts5
users3
websitepostgresql.org
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase