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 / update datetime

Author  Topic 

kneel
Starting Member

36 Posts

Posted - 2007-09-19 : 05:12:52
Hello All,

I am trying to insert birthdate "15/05/1981 10:45:14" into Birthday field from table. But I am receiving errror as follows

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

Does anybody know, how can I insert Or update this date?
Thanks in advance

--kneel

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-09-19 : 05:17:47
Add below statement before inserting date:

SET DATEFORMAT DMY

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Ballu
Starting Member

1 Post

Posted - 2007-09-19 : 05:20:12
hi just use this peice of code
INSERT INTO table_name(birthdate)
VALUES(to_date('15/05/1981 10:45:14' ,'fmdd/mm/yyyy hh:mi:ss');
Go to Top of Page

kneel
Starting Member

36 Posts

Posted - 2007-09-19 : 05:34:40
Thanks Harsh,
you solved my problem

--kneel
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-19 : 05:42:38
You are not using MICROSOFT SQL Server, are you?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-20 : 03:14:06
quote:
Originally posted by Ballu

hi just use this peice of code
INSERT INTO table_name(birthdate)
VALUES(to_date('15/05/1981 10:45:14' ,'fmdd/mm/yyyy hh:mi:ss');


FYI, this is MS SQL Server Forum and not ORACLE

Also you should always express dates in YYYYMMDD HH:MM:SS format

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -