Sorry, for quoting the manual but this might be just another example where
it could have the answer right away:
Hannes
http://www.mysql.com/doc/D/A/DATETIME.html
> The TIMESTAMP column type provides a type that you can use to automatically
> mark INSERT or UPDATE operations with the current date and time. If you have
> multiple TIMESTAMP columns, only the first one is updated automatically.
>
> Automatic updating of the first TIMESTAMP column occurs under any of the
> following conditions:
>
> * The column is not specified explicitly in an INSERT or LOAD DATA INFILE
> statement.
> * The column is not specified explicitly in an UPDATE statement and some
other
> column changes value. (Note that an UPDATE that sets a column to the value it
> already has will not cause the TIMESTAMP column to be updated, because if you
> set a column to its current value, MySQL ignores the update for efficiency.)
> * You explicitly set the TIMESTAMP column to NULL.
>
> TIMESTAMP columns other than the first may also be set to the current date and
> time. Just set the column to NULL or to NOW().
>
> You can set any TIMESTAMP column to a value different than the current date
> and time by setting it explicitly to the desired value. This is true even for
> the first TIMESTAMP column. You can use this property if, for example, you
> want a TIMESTAMP to be set to the current date and time when you create a row,
> but not to be changed whenever the row is updated later:
>
> * Let MySQL set the column when the row is created. This will initialize it
to
> the current date and time.
> * When you perform subsequent updates to other columns in the row, set the
> TIMESTAMP column explicitly to its current value.
>
> On the other hand, you may find it just as easy to use a DATETIME column that
> you initialize to NOW() when the row is created and leave alone for subsequent
> updates.
On 6/27/01 8:54 AM, "Pete Harlan" <[EMAIL PROTECTED]> wrote:
> TIMESTAMP is not the solution to his problem; he wants the date to
> default to now() when the record is created, not updated.
>
> There's currently no way to do this in MySQL; default values must be
> constants.
>
> --Pete
>
>
>
>> hi.
>>
>> check out the TIMESTAMP column type...maybe TIMESTAMP(14) as the column
>> type?
>> you can then format the date accordingly with...uh...DATE_FORMAT() in your
>> select statements...
>>
>> hth.
>> -ravi
>>
>>
>> -----Original Message-----
>> From: Richard Bates [mailto:[EMAIL PROTECTED]]
>> Sent: Tuesday, June 26, 2001 3:00 PM
>> To: [EMAIL PROTECTED]
>> Subject: Creating Table with a Default Datetime field
>>
>>
>> How do I get a default date time in the create table clause...
>>
>> I have tried
>>
>> Create table(
>> CreationDate DATETIME DEFAULT NOW(),
>> Info varchar(100)
>> );
>> Create table(
>> CreationDate DATETIME DEFAULT "NOW()",
>> Info varchar(100)
>> );
>>
>> Create table(
>> CreationDate DATETIME DEFAULT SYSDATE(),
>> Info varchar(100)
>> );
>> Create table(
>> CreationDate DATETIME DEFAULT "SYSDATE()",
>> Info varchar(100)
>> );
>>
>> Create table(
>> CreationDate DATETIME DEFAULT CURRENT_DATE(),
>> Info varchar(100)
>> );
>> Create table(
>> CreationDate DATETIME DEFAULT "CURRENT_DATE()",
>> Info varchar(100)
>> );
>>
>> All without the quote return with invalid syntax.
>> With the quote inserts "000-00-00 00:00:00" meaining invalid date.
>> ==================================
>> === Richard Bates
>> === TELEHOUSE America
>> ==================================
>>
>>
>>
>> ---------------------------------------------------------------------
>> Before posting, please check:
>> http://www.mysql.com/manual.php (the manual)
>> http://lists.mysql.com/ (the list archive)
>>
>> To request this thread, e-mail <[EMAIL PROTECTED]>
>> To unsubscribe, e-mail <[EMAIL PROTECTED]>
>> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>>
>>
>>
>> ---------------------------------------------------------------------
>> Before posting, please check:
>> http://www.mysql.com/manual.php (the manual)
>> http://lists.mysql.com/ (the list archive)
>>
>> To request this thread, e-mail <[EMAIL PROTECTED]>
>> To unsubscribe, e-mail
>> <[EMAIL PROTECTED]>
>> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php