创建一个表
create table test_student(
id int auto_increment,
firstName varchar(10) not null,
lastName varchar(10) nont null,
addtime date,
primary key(id)
)engine=innodb character set=utf8
插入语句
insert into test_student set firstName="zhang",lastName="san",addtime='2001-02-02';
insert into test_student set firstName="zhang",lastName="tian",addtime='2001-03-02';
insert into test_student set firstName="li",lastName="tian",addtime='2003-03-02';
查找 addtime 在等于 3月份的学生
select * from test_student where month(addtime)='03';
查找 addtime 等于 2001 年的学生
select * from test_student where year(addtime) ='2001';
//日期函数
// 返回日期date是星期几(1=星期天,2=星期一,……7=星期六,ODBC标准)
select dayofweek('2017-04-22') 返回 7;
//日期函数博客
http://www.cnblogs.com/zeroone/archive/2010/05/05/1727659.html
转载于:https://blog.51cto.com/9134122/1918521