服務(wù)熱線
153 8323 9821
select * from table1 where month(convert(varchar(10),btime,112))=9 //取出9月的數(shù)據(jù)
select year(convert(varchar(10),getdate(),120)) //得到當(dāng)前的年份
select month(convert(varchar(10),btime,120)) from table1 //得到當(dāng)前表數(shù)據(jù)的月份
select * from table1 where month(convert(varchar(10),btime,120))=3 //取出3月份的數(shù)據(jù)
在上面語句中,btime字段需要是日期格式