Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
need SQL Server stored procedure example code which Accept Datetime as parameter
Posted

And what is the Problem?

Does something like this not work?

SQL
CREATE PROCEDURE MYSP(@EXEC_DT DATETIME)
AS
BEGIN
    SET NOCOUNT ON;
....
END
 
Share this answer
 
Comments
Member 11012743 27-Jun-15 9:23am    
ok. but i am getting error like "Error converting data type nvarchar to datetime." when i am running my stored procedure even if i run it from SQL server and pass parameter value manually.
[no name] 27-Jun-15 10:01am    
The following works for me:

declare @MyDT datetime
set @MyDT='2012/04/06 12:23:45'
EXEC MYSP @MyDT
Member 11012743 27-Jun-15 10:03am    
ok i will try it
Member 11012743 27-Jun-15 9:24am    
thanks in advance
SQL
create PROCEDURE [dbo].[uspGetBlah]
{
  @fromDateTime DATETIME,
  @toDateTime DATETIME
}


exec uspGetBlah @fromDateTime='2015-06-01 00:00:00',@toDateTime='2015-06-26 00:00:00'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900