Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to pass datetime params?

Author  Topic 

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2011-09-28 : 10:18:44
I am trying to run this store proc the dates I am entering seem the problem:

EXEC @return_value = [dbo].[DBD_GET_MEDICINE_DETAIL]
@FACILITYKEY = N'ADLU',
@DATEFROM = N'''09012011''',
@DATETHRU = N'''09302011'''

I am getting this error message:

Msg 8114, Level 16, State 5, Procedure DBD_GET_MEDICINE_DETAIL, Line 0
Error converting data type nvarchar to datetime.

(1 row(s) affected)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-28 : 10:45:28
pass dates in universal unambigous format YYYYMMDD ie 20110930 etc
also i didnt understand why you're wrapping them around '' while passing to SP.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

paultech
Yak Posting Veteran

79 Posts

Posted - 2011-09-28 : 11:21:54
hi,

yes in order to get converted to datetime , it should be tranformed to universal format

the following link gets you the different datetime format

http://www.technoreader.com/SQL-Server-Date-Time-Format.aspx

good luck

paul Tech
Go to Top of Page
   

- Advertisement -