question

ArturBogusawski-1550 avatar image
0 Votes"
ArturBogusawski-1550 asked ArturBogusawski-1550 answered

Default date SSRS from current date.

I need Your help, I try uses default date in SSRS.

I need date:
Last day previous month in previous year.
Last day current month in previous year.

I have to generate my reports witch change default date.

For Example:
DP1 First start date
=IIF(
Day(Today())-DAY(DateAdd("d",-(Day(today)-1), Today)) <=7,
DateAdd(DateInterval.Month, -13, DateSerial(Year(Date.Now), Month(Date.Now), 1)),
DateAdd(DateInterval.Month, -12, DateSerial(Year(Date.Now), Month(Date.Now), 1))

DK1 First finish date
=IIF(
Day(Today())-DAY(DateAdd("d",-(Day(today)-1), Today)) <=7,
Last day previous month in previous year
Last day current month in previous year

)

DP2 Second start date
=IIF(
Day(Today())-DAY(DateAdd("d",-(Day(today)-1), Today)) <=7,
DateAdd(DateInterval.Month, -1, DateSerial(Year(Date.Now), Month(Date.Now), 1)),
DateSerial(Year(Date.Now), Month(Date.Now), 1)
)

DK2 Second finish date
=IIF(
Day(Today())-DAY(DateAdd("d",-(Day(today)-1), Today)) <=7,
DateAdd("d", -1, DateSerial(Year(Today()), Month(Today()), 1)),
Today()
)

sql-server-reporting-services
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ArturBogusawski-1550 ,
Has your issue been resolved?
If you have any questions, please feel free to let me know.
If the answer is helpful, please click "Accept Answer" and upvote it.
Best Regards,
Joy

0 Votes 0 ·
Joyzhao-MSFT avatar image
0 Votes"
Joyzhao-MSFT answered Joyzhao-MSFT edited

Hi @ArturBogusawski-1550 ,
For Last day previous month in previous year:

 =dateadd("m",0,dateserial(year(Today)-1,month(Today),0))

For Last day current month in previous year:

 =dateadd("m",1,dateserial(year(Today)-1,month(Today),0))

Preview:
108418-02.jpg

Best Regards,
Joy


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



02.jpg (5.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

WillFaulkner-2982 avatar image
0 Votes"
WillFaulkner-2982 answered WillFaulkner-2982 edited

For Last day previous month in previous year:


 =
 DateAdd(
         DateInterval.Day,
         day(today()) * -1,
         DateAdd(DateInterval.Year, -1, today())
        )

For Last day current month in previous year

 =
 DateAdd(
         DateInterval.Day,
         Day(today()) * -1,
         DateAdd(
                 DateInterval.Month, 
                 1,
                 DateAdd(DateInterval.Year, -1, today())
                 )
         )






5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ArturBogusawski-1550 avatar image
0 Votes"
ArturBogusawski-1550 answered

Thank You for Your help, I made report which sent purchases in periods.
When date month start < 7 Then send previous month.
Else current month.

Date 1 - all month previous year.
Date 2 - this month previous year.
Date 3 - this month current year.


109892-obraz.png



obraz.png (6.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.