List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:June 27 2001 5:55pm
Subject:Re: Creating Table with a Default Datetime field
View as plain text  
Well, almost true.
On insert, all timestamp fields are updated.
On update, only the first timestamp field is updated.
So, If you have two timestamp fields, you can get the result you want.

Pete Harlan 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:bates@stripped]
>> Sent: Tuesday, June 26, 2001 3:00 PM
>> To: mysql@stripped
>> 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 <mysql-thread77705@stripped>
>> To unsubscribe, e-mail
> <mysql-unsubscribe-ravi=webdream.com@stripped>
>> 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 <mysql-thread77719@stripped>
>> To unsubscribe, e-mail
> <mysql-unsubscribe-harlan=pointofchoice.com@stripped>
>> 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 <mysql-thread77817@stripped>
> To unsubscribe, e-mail
> <mysql-unsubscribe-gerald_clark=suppliersystems.com@stripped>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-- 
Gerald L. Clark
gerald_clark@stripped

Thread
Creating Table with a Default Datetime fieldRichard Bates26 Jun
  • RE: Creating Table with a Default Datetime fieldRavi Raman26 Jun
    • Re: Creating Table with a Default Datetime fieldPete Harlan27 Jun
      • Re: Creating Table with a Default Datetime fieldHannes Niedner27 Jun
        • Re: Creating Table with a Default Datetime fieldKaneda K28 Jun
          • Re: Creating Table with a Default Datetime fieldPaul DuBois28 Jun
      • Re: Creating Table with a Default Datetime fieldSherzod Ruzmetov27 Jun
        • RE: Creating Table with a Default Datetime fieldRavi Raman27 Jun
          • RE: Creating Table with a Default Datetime fieldSherzod Ruzmetov27 Jun
            • RE: Creating Table with a Default Datetime fieldRavi Raman27 Jun
              • RE: Creating Table with a Default Datetime fieldSherzod Ruzmetov27 Jun
      • Re: Creating Table with a Default Datetime fieldGerald Clark27 Jun
      • Re: Creating Table with a Default Datetime fieldRich Duzenbury27 Jun
      • Re: Creating Table with a Default Datetime fieldGerald Clark28 Jun