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
 error while inserting time

Author  Topic 

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2007-02-10 : 00:03:07
hi i am trying to insert time in my column which is in my table.my table has one column named as "intime" which has datatype as datetime.

i am doing thuis in vb.net.
i used this code in vb.net to get time:

dim dat as datetime=datetime.now.tostring("hh:mm:ss tt")
and i got time.but i am having this spc for insert:

create procedure sptimeinsert(@time datetime)
as

insert into time values:

An unhandled exception of type 'System.Data.SqlTypes.SqlTypeException' occurred in system.data.dll

Additional information: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM

please any one help to solve this error.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-10 : 02:24:19
[code]
create procedure sptimeinsert(@time datetime)
as
begin
insert into [my table] (intime) select @time
end
[/code]


KH

Go to Top of Page

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2007-02-10 : 03:07:21
hi khtan ,

again the same error iam getting

An unhandled exception of type 'System.Data.SqlTypes.SqlTypeException' occurred in system.data.dll

Additional information: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

please help me to solve this error
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-10 : 04:50:41
what is the value of @time that you pass in ?


KH

Go to Top of Page

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2007-02-10 : 05:08:33
hi khtan,

i am passing 1:30:00 pm n ow please help me
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-10 : 06:15:58
are you passing in as string ? try convert to datetime before passing in


KH

Go to Top of Page
   

- Advertisement -