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日期时间转为字符串
相关新闻
- 小程序登录流程图理解 2020-08-18
- 在C#中获取web.config中的配置信息 2021-08-23
- 小程序open-data头像样式 2021-04-10
- 小程序rich-text 富文本解析图片过大和图片路径的问题 2020-11-25
- C#中去掉字符串的最后一个字符 2020-11-23