Default Date and Time

Default Date and Time

am 26.06.2009 19:10:24 von Jason ML

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=gcdmg-mysql-2@m.gmane.org

Re: Default Date and Time

am 26.06.2009 19:43:41 von Max Bube

--001636c5b517927cff046d43e10b
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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=maxbube@gmail.com
>
>

--001636c5b517927cff046d43e10b--

RE: Default Date and Time

am 26.06.2009 20:54:37 von Jerry Schwartz

>-----Original Message-----
>From: Jason Todd Slack-Moehrle [mailto:mailinglists@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=jschwartz@the-
>infoshop.com





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org