Sunday 15 April 2012

mysql - Inserting NOW() value in datetime datatype is returning 0000-00-00 00:00:00 -



mysql - Inserting NOW() value in datetime datatype is returning 0000-00-00 00:00:00 -

i had database had working now() function, displaying right date. , after accidentally deleted it, created similar database, when inserted now() insert current current date, insert 0000-00-00 00:00:00.

the warning showed info truncated @ 'blog_date'. don't know how solve problem of acquiring current time using now(). below blog_details table, insert command, , error:

create table `blog_details` ( `blog_id` int(11) not null auto_increment, `title` char(200) not null, `blog_content` varchar(2500) notnull, `blog_date` datetime not null, `cat_name` varchar(30) null, primary key (`blog_id`)) engine=innodb default charset=latin1 auto_increment=1 ; insert `blog_details` (`title`, `blog_content`, `blog_date`, `cat_name`) values('breaking bad tv series', 'best series evar', 'now()', 'uncategorized');

+---------+------+------------------------------------------------+ | level | code | message | +---------+------+------------------------------------------------+ | warning | 1265 | info truncated column 'blog_date' @ row 1 | +---------+------+------------------------------------------------+

what you're inserting string "now()" different function phone call now().

as "now()" not valid date, goes in zero.

removing quotes should prepare issue.

mysql datetime

No comments:

Post a Comment