mysql 时间与日期

MySQL time and date

Posted by Lv Hui on June 22, 2014

将数据设置成日期类型

1
create table stu(sid smallint unsigned primary key auto_increment,birth date);

插入日期类数据

1
insert into stu set birth='1993/05/15';

日期相关函数

查询当前日期

1
select curdate();

查询当前时间

1
select curtime();

获得当前的日期和时间

1
select now();

获得日期的年份

1
select year('19920627');

查询1995后的数据

1
select * from stu where year(birth)>1995;