[ic] Recording Date of Item Creation?

Caleb Groom caleb at calebgroom.com
Sun Feb 13 18:05:28 EST 2005

On Sun, 2005-02-13 at 17:15 -0500, David Ratte wrote:
> > I am trying to figure out how to record the date an item/sku is added
> > to the database through Admin? I know how to add the new database
> > field.
> If your using an sql database, How about doing it in the database backend:
> [postgres example but others should be similar]
> psql databasename
> alter table products add column createdate date;
> alter table products alter column createdate set default now();
> \q
> now if you don't populate the field at all, the database will do it for you! 
> -Dave

It's a little different with MySQL.  Typically you cannot call a
function for a default value.

>From the create table docs [1]:
"The DEFAULT clause specifies a default value for a column. With one
exception, the default value must be a constant; it cannot be a function
or an expression. This means, for example, that you cannot set the
default for a date column to be the value of a function such as NOW() or
CURRENT_DATE. The exception is that you can specify CURRENT_TIMESTAMP as
the default for a TIMESTAMP column as of MySQL 4.1.2"

[1] http://dev.mysql.com/doc/mysql/en/create-table.html

More information about the interchange-users mailing list