数据库查询某年数据(sql server)
select *from 表名 where YEAR(存时间的字段名) =某年
select *from News where YEAR(addDate) =2017

月则用month函数
天则用day函数   

MySQL也有对应的方法,这里就不一一阐述了,使用方法一样

 

关于使用 DATEPART 函数用于返回日期/时间的单独部分,比如年、月、日、小时、分钟等等
SELECT DATEPART(yyyy,OrderDate) AS OrderYear,
DATEPART(mm,OrderDate) AS OrderMonth,
DATEPART(dd,OrderDate) AS OrderDay
FROM Orders
WHERE OrderId=1

 
                    
            
                

相关文章:

  • 2022-12-23
  • 2022-03-02
  • 2021-09-05
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
猜你喜欢
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案