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 2012 Forums
 Analysis Server and Reporting Services (2012)
 Conversion failed

Author  Topic 

tech2
Yak Posting Veteran

51 Posts

Posted - 2015-03-31 : 08:10:04
Hi,

Can someone tell me why the code below keeps giving me the error;

'Conversion failed when converting date and/or time from character string (Microsoft SQL Server, Error: 241'.

All I'm trying to accomplish is add (1) day to 'This Month Due Date'. The 'Status' Column indicates 'Late' when the two dates are the same. It should indicate 'On Time'. Thanks

,CASE WHEN 'This Month Receipt Date' <= 'This Month Due Date' THEN DATEADD(DAY, 1, 'On Time') ELSE 'Late' END AS Status

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-03-31 : 09:00:00
1. the first condition in your CASE statement is never true, since you are comparing strings.
2. DATEADD requires a datetime column or variable as the third parameter, but you have a string.
Go to Top of Page
   

- Advertisement -