Thread: Blank date field.. Help...

Blank date field.. Help...

From
ryan@fdcsmail.darktech.org
Date:
Hi,
  Is there any way that I can do, just to make my date columns to accept null/blank
  values? I use the latest stable version.

Ryan

Re: Blank date field.. Help...

From
Bruce Momjian
Date:
ryan@fdcsmail.darktech.org wrote:
> Hi,
>   Is there any way that I can do, just to make my date columns to accept null/blank
>   values? I use the latest stable version.

Uh, you sure can.  Can you show us the query that is failing.  Unless
the column is marked as NOT NULL, inserting a NULL should be fine.  It
will not accept '', only NULL.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Blank date field.. Help...

From
Richard Huxton
Date:
On Wednesday 17 Jul 2002 6:43 am, Bruce Momjian wrote:
> ryan@fdcsmail.darktech.org wrote:
> > Hi,
> >   Is there any way that I can do, just to make my date columns to accept
> > null/blank values? I use the latest stable version.
>
> Uh, you sure can.  Can you show us the query that is failing.  Unless
> the column is marked as NOT NULL, inserting a NULL should be fine.  It
> will not accept '', only NULL.

Those trying to produce cross-platform SQL should be aware that MySQL does
accept blank dates. It gets silently converted to "0000-00-00". This is
considered a feature (check their online manual for details).

Got bitten by this with a bug in one of my apps - couldn't understand what was
happening until I looked at the data being stored.

- Richard Huxton

Re: Blank date field.. Help...

From
Robert Treat
Date:
Unless you have stated NOT NULL in your table definition, you should be
able to enter NULL's. If you have stated NOT NULL, you'll need to
recreate the table.

CREATE TABLE "nulldatetest" (
   "withnull" date,
   "withoutnull" date NOT NULL
);

INSERT INTO "nulldatetest" ("withnull", "withoutnull") VALUES (NULL,
'2002-07-17')

Robert Treat

On Wed, 2002-07-17 at 09:30, ryan@fdcsmail.darktech.org wrote:
> Hi,
>   Is there any way that I can do, just to make my date columns to accept null/blank
>   values? I use the latest stable version.
>
> Ryan
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster