-- 当前日期时间 select now(); select now(3);-- 保留3位毫秒数 SELECT NOW(6); -- 保留6位毫秒数 -- 当前日期和时间 至秒 select current_timestamp; select current_timestamp(3); select current_timestamp(6); -- 当前日期,不包括时间 select curdate(); -- 当前时间 select curtime(); select DATE_FORMAT('2010-12-01 06:03:16.233999','%Y-%m-%d %T:%f'); select DATE_FORMAT('2010-12-01 07:03:16','%Y-%m-%d %h:%i:%s'); select timestampadd(hour, -8, '2008-08-08 12:00:00'); select date_add('2008-08-08 12:00:00', interval -8 hour); select get_format(date,'iso'); select get_format(datetime,'iso'); select period_diff(200808, 200801); select timestampdiff(year,'2002-05-01','2001-01-01'); -- drop table datetest; CREATE TABLE `datetest` (`time_id` int PRIMARY KEY auto_increment comment '自動增長ID',`CoAction` nvarchar(100) null default '', `createdate` TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), -- 保留3位毫秒数`createdate2` DATETIME(3) NOT NULL DEFAULT now(3),`createdate3` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), -- CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP`createdate4` DATETIME(6) NOT NULL DEFAULT now(6) -- 保留6位毫秒数) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='时间格式测试' AUTO_INCREMENT=1;SELECT * FROM datetest;insert into datetest(CoAction) values('geovindu,涂聚文');