SELECT Employee.[SSO]
, CASE WHEN ISDATE(EmployeeDetail.[MVCAStartDate])=1
THEN CAST(EmployeeDetail.[MVCAStartDate] AS datetime)
ELSE NULL
END AS dt1
FROM Employee, EmployeeDetail
WHERE Employee.[ID] = EmployeeDetail.[EmployeeID]
AND CASE WHEN ISDATE(EmployeeDetail.[MVCAStartDate])=1
THEN CAST(EmployeeDetail.[MVCAStartDate] AS datetime)
ELSE NULL
END <= CAST('02/04/2008' as DateTime)
ORDER BY CASE WHEN ISDATE(EmployeeDetail.[MVCAStartDate])=1
THEN CAST(EmployeeDetail.[MVCAStartDate] AS datetime)
ELSE NULL
END
|