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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 sql data type

Author  Topic 

vipinjha
Starting Member

21 Posts

Posted - 2012-03-15 : 07:11:55
Dear All,
I am getting this issue
The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.

in my table event_time is char i want to convert it into datetime datatype

please suggest the best possible way..

Reagrds,
Vipin jha

Vipin jha

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-03-15 : 07:21:20
Which format do you use for the date value in the nvarchar column?
See CAST & CONVERT in Books Online.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

vipinjha
Starting Member

21 Posts

Posted - 2012-03-15 : 07:33:02
i used both but not working

Vipin jha
Go to Top of Page

MPhoenix
Starting Member

4 Posts

Posted - 2012-03-15 : 07:37:15
Hi vipinjha,

Could you put the code of the conversion please ?
Go to Top of Page

rajarajan
Starting Member

48 Posts

Posted - 2012-03-15 : 12:56:11
declare @TestDateValue nvarchar(50)
set @TestDateValue = '01/01/05'
select cast(@TestDateValue as datetime) as NewTestDateTime

Try this
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-03-15 : 13:17:05
Do you have an example of an input value that is actually failing? The error message is indicating that the converted value is outside the allowed range (e.g. Year < 1753).

=================================================
Men shout to avoid listening to one another. -Miguel de Unamuno
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-15 : 13:22:17
ok..tried that..works for me

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -