March 29, 2006 at 9:15 pm
HI, can anybody help me to display the datepart from the date, which has date and time, i have used convert which is working fine, the problem is , when i am using the convert function in subquery for a date column and trying to show the value in main query, it gives me error saying
Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
March 29, 2006 at 11:46 pm
Can you paste your script? That way we might be able to spot whats causing the error
--------------------
Colt 45 - the original point and click interface
March 30, 2006 at 1:54 am
When you need to convert back to datetime, you should also specify the style :
declare @d1 datetime
set @d1 = getdate()
select dateASchar = convert(varchar(10),@d1,103)
go
declare @d1 datetime
set @d1 = getdate()
select charASdate_ERROR = convert(datetime,convert(varchar(10),@d1,103))
go
declare @d1 datetime
set @d1 = getdate()
select charASdate_OK = convert(datetime,convert(varchar(10),@d1,103),103)
go
/******* RESULT :
dateASchar
30/03/2006
(1 row(s) affected)
Server: Msg 242, Level 16, State 3, Line 3
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
charASdate_OK
2006-03-30 00:00:00.000
(1 row(s) affected)
*/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply