我正在尝试在SSRS中编写表达式:
如果今天的 DAY 是< =第15天,则返回上个月的付款期限16日至月的最后一天 如果今天的 DAY 是> = =第16天,则返回当前的第1天到第15天
这是我现在的表达,但它不起作用:
开始日期:
=IIF(DAY(TODAY) <= 15, DateAdd(DateInterval.Day, 1-Day(Today), Today), DateAdd(DateInterval.Month, -1, (DateAdd(DateInterval.Day, 16-Day(Today), Today)))),
IIF(DAY(TODAY) >= 16, dateadd("m",0,dateserial(YEAR(Today),MONTH(Today),1)
结束日期:
=IIF(DAY(TODAY) <= 15, DateAdd(DateInterval.Day, -1, DateSerial(Year(Date.Now), Month(Date.Now), 1)),
IIF(DAY(TODAY) >= 16, dateadd(dd,datediff(dd,datepart(dd,getdate()),15),getdate())
答案 0 :(得分:0)
使用以下表达式
开始日期:
=
Iif ( Day(Today())>15
, DateAdd( "d", -Day(Today())+1, Today())
, DateAdd("d", -Day(Today())+16, DATEADD("m", -1,Today()))
)
结束日期:
=
Iif ( Day(Parameters!DateParam.Value)>15
, DateAdd("d", -Day(Today())+15 , Today())
, DateAdd("d", -Day( Today()) , Today())
)
答案 1 :(得分:0)
我过去一周只需要做类似的事情......
--StartDate, if current day is more than 16, set to 1, else 16
=iif(DatePart("d",Today) >= 16, DateSerial(Year(Today), Month(Today), "1").AddMonths(-1), DateSerial(Year(Today), Month(Today),"16").AddMonths(-1))
--EndDate, if current day is more than 16 set to 15, else month end
=iif(DatePart("d",Today) >= 16, DateSerial(Year(Today), Month(Today), "15").AddMonths(-1), DateSerial(Year(Today), Month(Today),"1").AddDays(-1))