简体   繁体   English

如何在SSRS报表中获取当月的开始和结束日期

[英]How to get Current Month's Starting and End dates in SSRS report

I am working on SSRS Report, I have used 2 Date selection calendar, From Date and To date, So in From Date the Current months starting date should be as default date, and into the to date the Last date of the current month should be by default. 我正在使用SSRS报告,我使用了2个日期选择日历,“从日期”和“到”日期,因此在“从日期”中,“当前月份”的开始日期应作为默认日期,到“截止”日期,当前月份的“最后日期”应为默认。 Should I use Expression? 我应该使用表达式吗? or By SQL Query? 还是通过SQL查询?

Using T-SQL for 2012 version or higher it's quite simple, using DateFromParts to get the first day of the month and EOMonth to get the last day: 使用T-SQL 2012或更高版本这是相当简单,用DateFromParts得到月份和第一天EOMonth拿到最后一天:

DECLARE @Today Date = GETDATE();
DECLARE @FirstDayOfTheMonth date = DATEFROMPARTS(YEAR(@Today), MONTH(@Today), 1),
        @LastDayOfTheMonth date = EOMONTH(@Today);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM