Showing posts with label enddate. Show all posts
Showing posts with label enddate. Show all posts

Saturday, February 25, 2012

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
Try using the format: "mm/dd/yyyy", so it would be: 03/20/2006.|||Thanks Deepak,
This solved my problem.
Daren

problem with dates in parameter

Report query uses @.startDate and @.endDate for current date and tomorrow.
For currentdate I use =Today and that seems ok but if the report is run at
3PM the time shows 3PM rather than 00:00:00.
EndDate is more problematic. I've tried many different suggestions from
within this forum for obtaining tomorrow's date, including
=DateTime.Now.AddHours(24) and =DateTime.Now.AddDay(1) but cannot get it
right.
Can someone please help correct the syntax? Thanks!Do you need to use the full date and time, or is it sufficient to use date?
If you only need the date, you could get your dates by doing this sql query:
select convert(varchar(10), getdate(), 104) as today, convert(varchar(10),
dateadd("d", 1, getdate()), 104) as tomorrow
Just switch 104 to get the right date format.
Kaisa M. Lindahl Lervik
"Brian L" <BrianL@.discussions.microsoft.com> wrote in message
news:5D023CCF-CCB6-4A2B-960E-74091184774F@.microsoft.com...
> Report query uses @.startDate and @.endDate for current date and tomorrow.
> For currentdate I use =Today and that seems ok but if the report is run at
> 3PM the time shows 3PM rather than 00:00:00.
> EndDate is more problematic. I've tried many different suggestions from
> within this forum for obtaining tomorrow's date, including
> =DateTime.Now.AddHours(24) and =DateTime.Now.AddDay(1) but cannot get it
> right.
> Can someone please help correct the syntax? Thanks!