当月的第一天和最后一天
在 SQL Server 报告服务中;如何计算上个月的第一天和最后一天?
我知道我可以使用下面的表达式来获取当月的最后一天,但在尝试查找上个月的第一天和最后一天时我陷入了困境。
=DateSerial(Year(Now()), Month(Now()), "1").AddMonths(1).AddDays(-1)
In SQL Server Reporting Services; How can I calculate the first and last day of the previous month?
I know I can use the expression below to get the last day of the current month, but I'm stuck when trying to find the first and last of the previous month.
=DateSerial(Year(Now()), Month(Now()), "1").AddMonths(1).AddDays(-1)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
只是根据您的代码工作进行的猜测。
Just a guess based on your code working.
本月第一天:
=dateadd("m",0,dateserial(年(今天),月(今天),1))
本月最后一天:
=dateadd("m",1,dateserial(年(今天),月(今天),0))
上个月的第一天:
=dateadd("m",-1,dateserial(年(今天),月(今天),1))
下个月的第一天:
=dateadd("m",1,dateserial(年(今天),月(今天),1))
上个月的最后一天:
=dateadd("m",0,dateserial(年(今天),月(今天),0))
下个月的最后一天:
=dateadd("m",2,dateserial(年(今天),月(今天),0))
First day of this month:
=dateadd("m",0,dateserial(year(Today),month(Today),1))
Last day of this month:
=dateadd("m",1,dateserial(year(Today),month(Today),0))
First day of last month:
=dateadd("m",-1,dateserial(year(Today),month(Today),1))
First day of next month:
=dateadd("m",1,dateserial(year(Today),month(Today),1))
Last day of last month:
=dateadd("m",0,dateserial(year(Today),month(Today),0))
Last day of next month:
=dateadd("m",2,dateserial(year(Today),month(Today),0))
对于当前月份
上个月最后一天:
上个月第一天:
For current month
Previous month last day:
Previous month first day:
上个月最后日期:
Previous month last date:
上个月第一天:
First of previous month:
和
http://www.answermysearches.com/ssrs-how-to-set-a-default-parameter-to-the-first-day-of-the-month/2167/
and
http://www.answermysearches.com/ssrs-how-to-set-a-default-parameter-to-the-first-day-of-the-month/2167/
使用本机 VB 函数
上个月的第一天
上个月的最后一天
Using Native VB Functions
First Day of Previous Month
Last Day of Previous Month
我能够完成此任务,并通过使用以下命令以 mm/dd 格式显示它:
I was able to accomplish this, and show it in mm/dd format by using: