我每个月运行下面的查询SQL动态变化的日期时间
select A.a,
from A
inner join B on .....
where B.RemDate between '2013/09/01' and '2013/10/01'
我想将其添加为工作(从SQL Server代理)运行在每月的第2天。 是否可以自动改变
B.RemDate between '2013/09/01' and '2013/10/01'
到
B.RemDate between '1stday_of_previous_month' and '1st_day_of_current_month'
http://stackoverflow.com/questions/15144964/how-to-get-the-first-day-and-the-last-of-previous-month-using-sql – Andrew
什么版本SQL Server的使用?如果2012年 - 有一个函数['EOMONTH()'](http://technet.microsoft.com/en-us/library/hh213020.aspx)获取月份的最后一天,并轻松使用它获得第一个也(DATEADD -1)。如果没有检查其他答案。 –