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 2000 Forums
 Transact-SQL (2000)
 datetime

Author  Topic 

sach
Starting Member

4 Posts

Posted - 2002-07-30 : 05:30:43


can anybody tell me what is wrong with this procedure????

(emp_hire_date is a varchar (50)
datatype)

Alter Procedure t11
as

select DATEDIFF(day, convert(datetime,emp_hire_date), getdate()) as 'days' from t1

i get this error message...

'the conversion of a character data type to a datetime data type resulted in an out-of-range datetime value'.


thanks




macka
Posting Yak Master

162 Posts

Posted - 2002-07-30 : 05:42:05
What format is the emp_hire_date in ?

Can you provide an example ?

macka.

Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2002-07-30 : 05:44:55
quote:


i get this error message...

'the conversion of a character data type to a datetime data type resulted in an out-of-range datetime value'.




Most likely emp_hire_date is not in the expected date format. It's probably dd/mm/yyyy and the server is after mm/dd/yyyy.

Check the BOL CONVERT function, and look at the style parameter to see if one matches what you are converting from.

Go to Top of Page
   

- Advertisement -