Ben
asked on
Syntax error converting datetime from character string
I am getting the error message with the following code:
Case when 'firstinvoicedate' = dateadd(month,-14,getdate( )) then 'new work' else 'rolling work' end as 'Work Status'.
Case when 'firstinvoicedate' = dateadd(month,-14,getdate(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>I'll show you the entire query to clear things up for you
My comment is already pretty clear.
>SELECT CompanyName,Min(docketdate ) AS FirstInvoiceDate
Here you have an expression aliased as FirstInvoice Date, with the table aliased as latest, so your expression should be...
Case when latest.firstinvoicedate = dateadd(month,-14,getdate( )) then 'new work' else 'rolling work' end as 'Work Status'
My comment is already pretty clear.
>SELECT CompanyName,Min(docketdate
Here you have an expression aliased as FirstInvoice Date, with the table aliased as latest, so your expression should be...
Case when latest.firstinvoicedate = dateadd(month,-14,getdate(
ASKER
I tried that before but I get the following error messages:
Server: Msg 107, Level 16, State 2, Line 1
The column prefix 'latest' does not match with a table name or alias name used in the query.
Server: Msg 107, Level 16, State 1, Line 1
The column prefix 'latest' does not match with a table name or alias name used in the query.
Server: Msg 107, Level 16, State 2, Line 1
The column prefix 'latest' does not match with a table name or alias name used in the query.
Server: Msg 107, Level 16, State 1, Line 1
The column prefix 'latest' does not match with a table name or alias name used in the query.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window