I have to concatenate the date and time portion of two fields, which I have managed to do, then I need to test if the result is < getdate()
select count(cast(cast(DischargeDatenew as date) as datetime) + cast(DischargeTime as time))as Requiredby FROM [dbo].[Main]
where Location = 'Home' and ScriptTypeID = '1' and Requiredby < GETDATE()
Unfortunately the second Requiredby
comes up as an invalid column name. How can I get this query to work? Do I need a subquery?
Yes you will need subquery:
But I really think you want this: