problem with datetime value as parameter value
Hi all, I created a stored proc that has input datetime parameters (begindate and enddate), I tried the command: exec storedproc '20060320' in the query command part in Microsoft SQL Server Management Studio and it works but when I try to create a report dataset using the stored proc and execute it using value 20060320 it does not work. I even try using '20060320' and "20060320" as the value and it did not work also. I received the following error: TITLE: Microsoft Report Designer ------------------------------ An error occurred while executing the query. Failed to convert parameter value from a String to a DateTime. ------------------------------ ADDITIONAL INFORMATION: Failed to convert parameter value from a String to a DateTime. (System.Data) ------------------------------ String was not recognized as a valid DateTime. (mscorlib) ------------------------------ BUTTONS: OK ------------------------------ Anyone have any idea on how can I solve it or go about it?? Thanks in advance. Daren
March 20th, 2006 7:44am

Try using the format: "mm/dd/yyyy",so it would be:03/20/2006.
Free Windows Admin Tool Kit Click here and download it now
March 20th, 2006 8:14am

Thanks Deepak, This solved my problem. Daren
March 20th, 2006 8:41am

I have the same Problem, (in Oracle, but its the same) Where do I change the Format into "mm/dd/yyyyy"
Free Windows Admin Tool Kit Click here and download it now
November 27th, 2007 1:48pm

Hii For oracle you need to change in the Where clause of your query for the Datetime parameters as in oracle the same format will work after the conversion only from sql to oracle. So for that you need to change in your query as (for example - Where datetimeparameter = to_date(datetimeparameter,mm/dd/yyyy) ) just change in your query like this and see now i hope it should work fine anyway let me know if it works for you Thanks Mahasweta
November 27th, 2007 3:26pm

Thank you Mahasweta for your quick answer !!! But my problem , as i see it now, is not connected to Oracle or other DataBase. the problem is, the Parameter of dataType "datetime" accept dates only in format "mm/dd/yyyy" how can I change it ?
Free Windows Admin Tool Kit Click here and download it now
November 27th, 2007 5:15pm

it doesnt work for me in this case as i am still gettin the error of "Error converting data type varchar to datetime." is there any other way on on declaration part or probably someone can guide to solve this error? ALTER PROCEDURE [dbo].[tray_history] ( @datefrom as datetime ) AS and the other part of the stored procedure is: begin if(@history)<>'' begin if (@datefrom)<>'' begin set @strSQL='SELECT * FROM history_view WHERE Phone_Number LIKE ''%' + (@history) + '%'' and History_CreatedDate=' + cast(@datefrom as datetime) end pls advice?!!
July 17th, 2008 5:30am

Hi, In the data part while excuting the stored procedure you have to pass default date like(01/01/1999). Thnaks SOMU
Free Windows Admin Tool Kit Click here and download it now
December 2nd, 2010 3:46am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics