Link to home
Start Free TrialLog in
Avatar of PHS_IT
PHS_IT

asked on

CAN I USE DATEPART IN ( ) ?

What is wrong with this statement?  I know I must have a comma out of place, or a ( in the wrong place.  Or can I not use IN with DATEPART???

CASE WHEN TPR200_EMPLOYEE_MASTER.lst_rvw_dt IS NULL AND
DATEPART(m, TPR200_EMPLOYEE_MASTER.nxt_rvw_dt) IN ('5', '6', '7')) THEN 1
         ELSE 0 END AS CountDueQtr1
Avatar of ptjcb
ptjcb
Flag of United States of America image

What is the error message?
Avatar of PHS_IT
PHS_IT

ASKER

Msg 170, Level 15, State 1, Line 67
Line 67: Incorrect syntax near ')'.
ASKER CERTIFIED SOLUTION
Avatar of ptjcb
ptjcb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
without seeing the entire script - it may be the extra ) after the list. Try this one:


CASE WHEN TPR200_EMPLOYEE_MASTER.lst_rvw_dt IS NULL AND
DATEPART(m, TPR200_EMPLOYEE_MASTER.nxt_rvw_dt) IN ('5', '6', '7') THEN 1
         ELSE 0 END AS CountDueQtr1
You have an extra close parathensis
DATEPART(m, TPR200_EMPLOYEE_MASTER.nxt_rvw_dt) IN ('5', '6', '7') THEN 1
Avatar of PHS_IT

ASKER

ptjcb,
Thanks, you caught it.  I stared at it too long.  CmdoProg2, you were right also, but I was already working with ptjcb, so I will award the points there.  Thanks for your assistance.