I am looking into a view and part of the view as this code
RIGHT ('00000000' + OrderNumber, 8) + '_' + SUBSTRING(ProcessDate, 7, 4) +
RIGHT ('00' + SUBSTRING(ProcessDate, 4, 2), 2) + RIGHT
('00' + SUBSTRING(ProcessDate, 1, 2), 2) + '_' + CASE WHEN CONVERT
(int , LEFT (ProcessTime , 2)) < CASE WHEN DATEPART(weekday ,
CONVERT (datetime , isnull(CONVERT (datetime , RIGHT (processdate , 4) +
'-' + substring(processdate , 4 , 2) + '-' + LEFT (processdate , 2)) ,
'2000-01-01'))) = 6 THEN 13 ELSE 14 END THEN '1' ELSE '2'
END
Unfortunately I am not so hot on code but when running the view I am getting this error message
"The conversion of a varchar data type in a datetime data type resulted in an out of range value"
I am not sure which part may be incorrect and appreciate it may not be evident without know all the tables and field definitions etc....
But if anyone as any ideas what may be wrong it would be useful, thanks
RIGHT ('00000000' + OrderNumber, 8) + '_' + SUBSTRING(ProcessDate, 7, 4) +
RIGHT ('00' + SUBSTRING(ProcessDate, 4, 2), 2) + RIGHT
('00' + SUBSTRING(ProcessDate, 1, 2), 2) + '_' + CASE WHEN CONVERT
(int , LEFT (ProcessTime , 2)) < CASE WHEN DATEPART(weekday ,
CONVERT (datetime , isnull(CONVERT (datetime , RIGHT (processdate , 4) +
'-' + substring(processdate , 4 , 2) + '-' + LEFT (processdate , 2)) ,
'2000-01-01'))) = 6 THEN 13 ELSE 14 END THEN '1' ELSE '2'
END
Unfortunately I am not so hot on code but when running the view I am getting this error message
"The conversion of a varchar data type in a datetime data type resulted in an out of range value"
I am not sure which part may be incorrect and appreciate it may not be evident without know all the tables and field definitions etc....
But if anyone as any ideas what may be wrong it would be useful, thanks