Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Calculation column

Status
Not open for further replies.

cabbey77

Technical User
Aug 6, 2004
68
US
Hello,

I want to create a column whereby if the Updated_DateTime field is null, then convert the Created Date Time Field, otherwise, convert the Updated Date Time field and call it LastUpdatedDate.

Can someone tell me why Im getting the following error: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'AS', from the following code:

SELECT If(IsNull(CD.LastUpdated_DateTime, Convert(VarChar(8), CD.CreatedDateTime, 1), Convert(VarChar(8), CD.LastUpdated_DateTime, 1) AS [LastUpdatedDate],
FROM HubInv.Call_Details AS CD
 
Fabulous, looks like I made things too complicated by far!! Won't be the last time.

Thank you!

C
 
To answer your other question about why you got the syntax error...count your parenthesis.

You have 6 open parenthesis '(' but only 4 close parenthesis ')'.

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top