Solved

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

Posted on 2011-02-28
11
894 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 35001010
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
ID: 35001017
oops, i meant:  SELECT DATEADD(d, @Days, '02/28/2011')
0
 

Author Comment

by:nordicgirl
ID: 35001091
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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 17

Expert Comment

by:pssandhu
ID: 35001125
Try this:

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

Expert Comment

by:pssandhu
ID: 35001153
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
 

Author Comment

by:nordicgirl
ID: 35001662
tried the convert command with no luck.
0
 
LVL 17

Expert Comment

by:pssandhu
ID: 35001801
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
ID: 35002410
the datatype of the field in the table is datetime
0
 
LVL 17

Expert Comment

by:pssandhu
ID: 35002446
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
ID: 35009004
Never mind, I decided to use a stored proc instead. thanks anyway.
0
 

Author Closing Comment

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

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL - Curser to do an insert based on a select 2 29
SSRS Page Header from Group Data 2 56
When are cursors useful? 8 60
T-SQL Query 9 35
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 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