服務熱線
153 8323 9821
select * from table1 where month(convert(varchar(10),btime,112))=9 //取出9月的數據
select year(convert(varchar(10),getdate(),120)) //得到當前的年份
select month(convert(varchar(10),btime,120)) from table1 //得到當前表數據的月份
select * from table1 where month(convert(varchar(10),btime,120))=3 //取出3月份的數據
在上面語句中,btime字段需要是日期格式
上一篇:SQL日期時間轉為字符串
下一篇:.net 時間函數大全