Im trying to do this
SELECT CAST(date AS datetime) + CAST(time AS datetime) AS NewDT, variable, value
FROM batch
WHERE (NewDT <= @BatchStartDate)
But i get the error “Invalid colum name NewDT”
The problem is that date and time is in two colums in the database.
Guessing you are using MS SQL Server. You can’t reference an alias on the
WHEREclause, you should use the fullCAST(date AS datetime) + CAST(time AS datetime)so it would be: