Solved

cannot use a parameter for the number of days value in DateAdd for an SSRS dataset

Posted on 2011-02-28
11
882 Views
Last Modified: 2012-05-11
I am having trouble with the DateAdd function in SSRS 2005.  I want the user to enter a parameter for the number of days.  I want to filter a date range in the dataset with the result set.

For example,

= DATEADD(d, 0, '02/28/2011')  works fine.

= DATEADD(d, @Days, '02/28/2011') gives me this error:

Error Source:  System.Data

Error Message:  Failed to convert parameter value from a Decimal to a DateTime.


I have tried setting the parameter data type to string, int, bool, datetime, and double and nothing works.  

Please Help!

Thanks.

0
Comment
Question by:nordicgirl
  • 5
  • 4
  • 2
11 Comments
 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
It seems to work for me.  Are you sure the error is referring to this statement?


declare @Days int
select  @Days = 5
DATEADD(d, @Days, '02/28/2011')
0
 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
oops, i meant:  SELECT DATEADD(d, @Days, '02/28/2011')
0
 

Author Comment

by:nordicgirl
Comment Utility
this works ok in SQL Management Server, but not in Reporting Services.  I define the parameter in the report, link it to the dataset, and then try to filter the dataset with it.
0
 
LVL 17

Expert Comment

by:pssandhu
Comment Utility
Try this:

DATEADD(d, Convert(@Days as INt), '02/28/2011')
0
 
LVL 17

Expert Comment

by:pssandhu
Comment Utility
Also make sure the parameters data type in your report is set as "Integer" and if you are passing the parameter value to a stored proc, the parameter in the stored proc is INT data type.

P.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:nordicgirl
Comment Utility
tried the convert command with no luck.
0
 
LVL 17

Expert Comment

by:pssandhu
Comment Utility
The error is saying that it trying to convert from a Decimal. Can you tell what parameter or value is declared as Decimal.

The field in the table, can you tell what datatype is that.
0
 

Author Comment

by:nordicgirl
Comment Utility
the datatype of the field in the table is datetime
0
 
LVL 17

Expert Comment

by:pssandhu
Comment Utility
Are you able to send me your report. Not the whole project just the report. YOu can find it in the projects folder. It will have an extension of rdl.

Change the extension to txt and upload. I won't be able to run it but I should be able to see all the settings.

P.
0
 

Accepted Solution

by:
nordicgirl earned 0 total points
Comment Utility
Never mind, I decided to use a stored proc instead. thanks anyway.
0
 

Author Closing Comment

by:nordicgirl
Comment Utility
did not get an answer; ended up using a stored proc to get around the issue.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now