Curdate() returns a datetime, which you are pushing into a date field. It is truncating the time part. Just truncate it and you should be fine :)
Walter On Fri, Jun 5, 2009 at 5:56 AM, Keith Edmunds<k...@midnighthax.com> wrote: > I'm very new to triggers, so I suspect I've done something naive. > > When a row is inserted into a table, I want populate a 'date' column with > the date 45 days hence. I've created a trigger: > > CREATE TRIGGER `test`.`setExpiryDate` BEFORE INSERT ON `test`.`mysql_auth` > FOR EACH ROW SET NEW.expires = curdate()+interval 45 day > > It works, doing what I want, but I get the following error: > > Warning: #1265 Data truncated for column 'expires' at row 1 > > The table is: > > CREATE TABLE `mysql_auth` ( > `id` int(11) NOT NULL auto_increment, > `user` varchar(25) NOT NULL, > `password` varchar(32) NOT NULL, > `expires` date NOT NULL, > `login_failures` int(11) NOT NULL default '0', > `last_login_failure` datetime default NULL, > PRIMARY KEY (`id`) > ) > > Can someone help me understand what it happening here, and how to fix it? > > Thanks > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql?unsub=li...@olindata.com > > -- Walter Heck, Engineer @ Open Query (http://openquery.com) Affordable Training and ProActive Support for MySQL & related technologies Follow our blog at http://openquery.com/blog/ OurDelta: free enhanced builds for MySQL @ http://ourdelta.org -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org