Set default value for date/time to previous month
Hi All
I have two date/time parameters in my report and I want to set the default value for both the parameters
For start date parameter I want the first date of previous month and for end date parameter I want the last date of previous month.
Can someone please point me to the right direction
Thanks
Rone
June 2nd, 2012 4:57am
Hi Rone,
These links can be helpful for you:
http://www.bidn.com/blogs/hardikabhavsar/bidn-blog/1639/default-date-parameters-in-ssrs
http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/584a98ae-bb75-4740-9198-e6be3c1aec12/
Regards,
Manoj
*Happy to help
http://experiencingmsbi.blogspot.com/
Free Windows Admin Tool Kit Click here and download it now
June 2nd, 2012 6:05am
Hi There
Please use for the first day use this one
=DATEADD("M",-1, Dateadd("d",1-DATEPART("d",Today()),Today))
=DATEADD("M",-1, Dateadd("d",1-DATEPART("d",Today()),Today))
For end date
=DateSerial(Year(Now()), Month(Now()), "1").AddMonths(0).AddDays(-1)
=DateSerial(Year(Now()), Month(Now()), "1").AddMonths(0).AddDays(-1)
If you have any question please let me know.
Many Thanks
Syed Qazafi Anjum
Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful
June 2nd, 2012 6:22am
Hi Ronie,
You can define a default value parameter expression for start date as:
=DATEADD("M",-1, Dateadd("d",1-DATEPART("d",Today),Today))
and default value parameter expression for end date as:
=DateSerial(Year(Now), Month(Now), "1").AddMonths(0).AddDays(-1).AddHours(23).AddMinutes(59).AddSeconds(59)
The reason i have included hours minutes and second in end date parameter is for end date you always want the data till the end of the day.
You can also define two dataset and set your default value of parameter to get result from query
Start Date Parameter will be getting value from dataset having query:
Select DATEADD(mm, DATEDIFF(M,0,GETDATE())-1,0) as StartDate
EndDate Parameter will be getting value from dataset having query:
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) as EndDate
Free Windows Admin Tool Kit Click here and download it now
June 2nd, 2012 3:28pm
Thanks all for your response. it helped
RegardsRone
June 3rd, 2012 12:22am