| Author |
Topic |
|
nobby
Yak Posting Veteran
58 Posts |
Posted - 2006-10-26 : 05:34:56
|
| When i try to insert into a datetime field i keep getting this error.Msg 242, Level 16, State 3, Procedure Sproc_01220_Tour_PendingPayment, Line 27The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.The statement has been terminated.(1 row(s) affected) i am passing to the date parameters the date in this format dd/mm/yyyyAny ideasALTER PROCEDURE [dbo].[Sproc_01220_Tour_PendingPayment]@MemberId int =Null,@TourStartDate DateTime =Null,@Initial_TourQty int =Null,@PaidUntill DateTime =NullASBEGIN--OverallSET NOCOUNT ON; BEGIN--Insert INSERT INTO Tbl_01040_Tour_Join_PendingPayment (Pend_MemberId, Pend_TourStartDate, Pend_Initial_TourQty, Pend_PaidUntill) VALUES (@MemberId, @TourStartDate, @Initial_TourQty, @PaidUntill) END--Insert |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-26 : 05:36:40
|
| Try to pass the parameter as yyyymmdd instead.Peter LarssonHelsingborg, Sweden |
 |
|
|
sachinsamuel
Constraint Violating Yak Guru
383 Posts |
Posted - 2006-10-26 : 06:40:28
|
| Or else specify the date format in the store procedureLikeALTER PROCEDURE [dbo].[Sproc_01220_Tour_PendingPayment]@MemberId int =Null,@TourStartDate DateTime =Null,@Initial_TourQty int =Null,@PaidUntill DateTime =NullASSet nocount onSet Dateformat DMYINSERT INTO Tbl_01040_Tour_Join_PendingPayment(Pend_MemberId,Pend_TourStartDate,Pend_Initial_TourQty,Pend_PaidUntill)VALUES (@MemberId,@TourStartDate,@Initial_TourQty,@PaidUntill)Set nocount offDon't sit back because of failure. It will come back to check if you still available. -- Binu |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-26 : 06:55:54
|
| I don't think that is an issue since the parameter, internally in SP, is datetime. I think it is the first time when parameter is assigned that the error occurs.Peter LarssonHelsingborg, Sweden |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-26 : 08:37:03
|
quote: Originally posted by sachinsamuelSet Dateformat DMY
This won't help.As Peter suggested, pass in the date as universal format YYYYMMDD orchange the input parameter as varchar and convert to datetime internally in the SPALTER PROCEDURE [dbo].[Sproc_01220_Tour_PendingPayment]@MemberId int =Null,@TourStartDateChar varchar(10) = Null,AsBegin declare @TourStartDate datetime select @TourStartDate = convert(datetime, @TourStartDateChar, 103) KH |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-10-26 : 09:20:48
|
quote: Originally posted by khtan...orchange the input parameter as varchar and convert to datetime internally in the SP...
Blasphemy!!!Leave it as a datetime parameter, otherwise you have to put a whole lot more checking in the strored procedure and then convert it to datetime.CODO ERGO SUM |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-26 : 09:22:40
|
quote: Originally posted by Michael Valentine Jones
quote: Originally posted by khtan...orchange the input parameter as varchar and convert to datetime internally in the SP...
Blasphemy!!!Leave it as a datetime parameter, otherwise you have to put a whole lot more checking in the strored procedure and then convert it to datetime.CODO ERGO SUM
Yes it is  KH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-26 : 09:37:48
|
| http://sql-server-performance.com/fk_datetime.aspMadhivananFailing to plan is Planning to fail |
 |
|
|
|