RE: Default Date and Time

2009-06-26 Thread Jerry Schwartz


>-Original Message-
>From: Jason Todd Slack-Moehrle [mailto:mailingli...@mailnewsrss.com]
>Sent: Friday, June 26, 2009 1:10 PM
>To: mysql@lists.mysql.com
>Subject: Default Date and Time
>
>Hi All,
>
>I want to create a table that defaults to current_date and current_time.
>
[JS] Would a timestamp data type work for you? It includes both the date and
time, and is updated whenever the record is changed. If not, you'll have to
assign values in your INSERT statement using the time/date functions.
>I have:
>
>CREATE TABLE `personalevent`(
>   `pevent` mediumint(10) NOT NULL,
>   `eventid` mediumint(10) NOT NULL,
>   `userid` mediumint(10) NOT NULL,
>   `username` varchar(10) NOT NULL,
>   `password` varchar(10) NULL,
>   `country` varchar(45) NULL,
>   `zipcode` varchar(5) NULL,
>   `city` varchar(35) NULL,
>   `hstate` varchar(45) NULL,
>   `exclusive` varchar(7) NULL,
>   `eventtime` time NULL DEFAULT current_time(),
>   `eventdate` date NULL DEFAULT current_date(),
>   `eventdura` varchar(35) NULL,
>   `daysevent` varchar(10) NULL,
>   `crowd` varchar(25) NULL,
>   `venue` varchar(50) NULL,
>   `activitytype` varchar(45) NULL,
>   `actdetails` varchar(255) NULL,
>   `encodedby` varchar(100) NULL,
>   `curmo` varchar(2) NULL,
>   `pageweb` varchar(50) NULL,
>   PRIMARY KEY (`pevent`)
>) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
>But this throws a syntax error. I have tried Now() as well.
>
>What am I doing wrong?
>
>Best,
>
>-Jason
>
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe:http://lists.mysql.com/mysql?unsub=jschwa...@the-
>infoshop.com





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Default Date and Time

2009-06-26 Thread Max Bube
Hi Jason

The DEFAULT value can't be an expression.



2009/6/26 Jason Todd Slack-Moehrle 

> Hi All,
>
> I want to create a table that defaults to current_date and current_time.
>
> I have:
>
> CREATE TABLE `personalevent`(
>`pevent` mediumint(10) NOT NULL,
>`eventid` mediumint(10) NOT NULL,
>`userid` mediumint(10) NOT NULL,
>`username` varchar(10) NOT NULL,
>`password` varchar(10) NULL,
>`country` varchar(45) NULL,
>`zipcode` varchar(5) NULL,
>`city` varchar(35) NULL,
>`hstate` varchar(45) NULL,
>`exclusive` varchar(7) NULL,
>`eventtime` time NULL DEFAULT current_time(),
>`eventdate` date NULL DEFAULT current_date(),
>`eventdura` varchar(35) NULL,
>`daysevent` varchar(10) NULL,
>`crowd` varchar(25) NULL,
>`venue` varchar(50) NULL,
>`activitytype` varchar(45) NULL,
>`actdetails` varchar(255) NULL,
>`encodedby` varchar(100) NULL,
>`curmo` varchar(2) NULL,
>`pageweb` varchar(50) NULL,
>PRIMARY KEY (`pevent`)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
> But this throws a syntax error. I have tried Now() as well.
>
> What am I doing wrong?
>
> Best,
>
> -Jason
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:http://lists.mysql.com/mysql?unsub=maxb...@gmail.com
>
>