SQL server获取上月数据

  • Post author:
  • Post category:其他


select * from ProcessStatus where DATEPART(yyyy,create_time) = DATEPART(yyyy,dateadd(m,-1,GETDATE())) and DATEPART(m,create_time) = DATEPART(m,dateadd(m,-1,GETDATE())); 

select * from ProcessCode where DATEPART(yyyy,create_time) = DATEPART(yyyy,dateadd(m,-1,GETDATE())) and DATEPART(m,create_time) = DATEPART(m,dateadd(m,-1,GETDATE()));

select * from ProcessData where DATEPART(yyyy,create_time) = DATEPART(yyyy,dateadd(m,-1,GETDATE())) and DATEPART(m,create_time) = DATEPART(m,dateadd(m,-1,GETDATE())) 



版权声明:本文为wlpz0528原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。