April 12, 2012 at 4:54 am
Hi,
What is the expression to set the default date of date parameter to getdate()-1. I want the SSRS report to choose the Startdate as previous date and end date as current date.
I set the default value of parameter as =Today(), which displays current date, how to set it to previous date? Any ideas what should be the expression?
Thanks
April 12, 2012 at 7:15 am
Try this:
=DateAdd("d",-1,Today())
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
April 12, 2012 at 7:22 am
Thanks. It worked.
March 27, 2015 at 4:20 am
Many thanks
July 17, 2015 at 4:58 am
Very helpful! Thanks!
February 4, 2016 at 11:40 am
For some reason the VB functions like "=Today()" would not work for the default value for a date parameter (it gave me the red angry line but would not say why it didn't like it).
I ended up making a dataset as follows and it worked fine.
select convert(date,convert(char(10),getdate(),101)) as Today
March 10, 2016 at 7:02 am
so in SSRS what if I wanted the date to always be tomorrows date?
March 10, 2016 at 11:16 am
rcooper 78099 (3/10/2016)
so in SSRS what if I wanted the date to always be tomorrows date?
You should be able to come up with that yourself.
This is the calculation to find "yesterday":
=DateAdd("d",-1,Today())
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
March 10, 2016 at 12:15 pm
=DateAdd("d",-1,Today())
I am assuming it would be
=DateAdd("d",+1,Today())
or
=DateAdd("d",1,Today())
which have both not worked.
March 10, 2016 at 12:44 pm
rcooper 78099 (3/10/2016)
=DateAdd("d",-1,Today())I am assuming it would be
=DateAdd("d",+1,Today())
or
=DateAdd("d",1,Today())
which have both not worked.
In what sense?
Is an error returned?
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
March 10, 2016 at 12:46 pm
rcooper 78099 (3/10/2016)
=DateAdd("d",-1,Today())I am assuming it would be
=DateAdd("d",+1,Today())
or
=DateAdd("d",1,Today())
which have both not worked.
What do you mean by have not worked? How are you assigning the default value?
I just tested both approaches and they work.
Can you share more details?
March 10, 2016 at 12:46 pm
I am told that both of those are incorrect
with a basic error of Value not recognized.
March 10, 2016 at 12:50 pm
Did you follow these steps?
- Open the Parameter properties.
- Set Data type to Date/Time.
- Go to Default Values tab.
- Click on the formula (fx) button.
- Write or paste the expression.
- Click OK to confirm the expression, then again to confirm the changes on the parameter properties.
- Test your report.
March 10, 2016 at 12:50 pm
The value provided for the report parameter 'ChkPrintDate' is not valid for its type.
This is the error produced on my front end.
March 10, 2016 at 12:53 pm
unfortunately I do not have those options see screen shot attached.
Luis Cazares (3/10/2016)
rcooper 78099 (3/10/2016)
=DateAdd("d",-1,Today())I am assuming it would be
=DateAdd("d",+1,Today())
or
=DateAdd("d",1,Today())
which have both not worked.
What do you mean by have not worked? How are you assigning the default value?
I just tested both approaches and they work.
Can you share more details?
Viewing 15 posts - 1 through 15 (of 15 total)
You must be logged in to reply to this topic. Login to reply