List:General Discussion« Previous MessageNext Message »
From:James Lyon Date:January 22 2000 11:36am
Subject:Re: How to add a default CURDATE value ?
View as plain text  
> I new use of mysql.
>
> I would like to know if a table I could set a "automatic" field to
> CURRENT_DATE as:
> CREATE TABLE my_table (
>         date DATE DEFAULT CURRENT_DATE());
>
> I know is set of commands isn't working... But I would like to do something
> like that if possible

Do the following ...

CREATE TABLE my_table (date_added DATE);

and then, when INSERTing rows, set the date to NULL and it'll be stamped with
the current date automatically...

INSERT INTO my_table (date_added) VALUES (NULL);

Note that I've renamed the field from "date" to "date_added" to avoid ambiguity
-- "date" is a reserved word so not such a good choice for a field name.

James.

Thread
How to add a default CURDATE value ?Frederic SAVOIR18 Jan
  • Re: How to add a default CURDATE value ?James Lyon22 Jan
  • Re: How to add a default CURDATE value ?Faisal Nasim22 Jan
  • Re: How to add a default CURDATE value ?James Lyon22 Jan