I am trying to configure a computed column using Scalar function. I need to set a BIT on column status based on dates.
CREATE FUNCTION dbo.setStatus(@StartDate datetime, @EndDate datetime)
RETURNS bit
AS
BEGIN
RETURN (@StartDate < GETDATE() && GETDATE() < @EndDate)
END
GO
I am seeing error in ssms that the symbol "<" is invalid.
getdate()returns current date & time. If you only required today's date, use useconvertorcastit to date data typeconvert(date, getdate())