Page 1 of 1

null date

Posted: Fri May 18, 2001 4:12 pm
by sourceuno
How can I insert a NULL value into a date type column? I tried using:

insert mytable values(NULL)

But that doesn't work.

null date

Posted: Fri May 18, 2001 4:39 pm
by Kai
Quote the NULL:

insert into mytable values('NULL');

null date

Posted: Fri May 18, 2001 5:07 pm
by sourceuno
I'm actually trying to add a date column to a table by creating a new table with the new column and then trying to insert the data from the old table into the new table, but I get the following error:

Types for field ErrDate are not compatible date != char

Here's what I'm doing:

error1 is identical to error2 but doesn't have the date field Errdate.

create table error2(id counter,Errdate date, field1 varchar(80))
insert into error 2 select id,'NULL',field1 from error1

null date

Posted: Fri May 18, 2001 5:49 pm
by Kai
Explicitly convert the NULL:

insert into error2 select id, convert('NULL', 'date'), field1 from error1;