I have the following procedure interface:
Create procedure [dbo].[InsertItemDetails] @TimeItemAdded datetime
When I call it this way:
EXEC [dbo].[InsertItemDetails] @TimeItemAdded = N'20/07/2012 00:00:00';
I get this error:
Msg 8114, Level 16, State 5Error converting nvarchar to datetime data type.
Depending on your regional settings, the parameter you pass for @TimeItemAddedmay not be recognized.
@TimeItemAdded
You must pass the date as:
20120720
Use an unambiguous string literal for your date. In this case:
EXEC dbo.InsertItemDetails ... , @TimeItemAdded = '20120720';
, , , . .
, m/d/y, , , , , , , ..
datetime, http://www.sql-server-helper.com/tips/date-formats.aspx
varchar -, . :
SELECT CONVERT(DATETIME, '20/07/2012 00:00:00', 103)
103 - , .
SQL read your date as 7/20/2012which is invalid, you can pass your date objects in a more secure format, yyyy-MM-ddfor example:2012-07-20
7/20/2012
yyyy-MM-dd
2012-07-20