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
 Insert date in Sql Server

Author  Topic 

rohan.rishi.2007
Starting Member

8 Posts

Posted - 2011-07-14 : 05:54:33
Hello to every one i m trying to insert date in Sql server but it gives
me error. Error is saying

"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The statement has been terminated."

i am using sql server as back end of my project and vb.net as front end.

my query is

Insert into bookingDet(cuId,inDate,bDate,adult,child,status) values(1,'14/07/2011','14/07/2011 03:21:59 PM',1,0,'booked')


here indate and bdate is datetime datatype

Plz help me.

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-07-14 : 05:58:42
When inserting dates to a sql server table you should always use the format YYYYMMDD HH:MM:SS. Anything else is prone to be misinterpreted.

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
Go to Top of Page
   

- Advertisement -