Reputation: 1074
I run into this error with my statement:
insert into messages ([from], [to], [message], Subject, status, senderID,
PassengerID, Taxis, bags, passengers, dest, Comments, [when])
values(2, 81, '2', 'Bid', 1, 2,
2, 2, 2, 2, '2', '2', CONVERT(smalldatetime, '25.7.2016 13:01'))
I get this error:
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.
When running the same statement on the console, it works perfectly fine!
Upvotes: 2
Views: 981
Reputation: 6656
You need to specify an appropriate style
parameter in Convert function like this -
Insert into messages ([from],[to],[message],Subject,status,senderID,PassengerID,Taxis,bags,passengers, dest, Comments,[when])
values(2,81,'2','Bid',1,2,2,2,2,2,'2','2',CONVERT(smalldatetime, '25.7.2016 13:01', 104))
Upvotes: 1
Reputation: 49
This has to do with your server settings. Seems that your server waits for an US Date format (mm dd yyy) while you enter a european format (dd mm yyyy).
Upvotes: 1