Msg 195, Level 15, State 10, Line 6 'Datetime' Is Not a Recognized Built-in Function Name
I Am Getting the Error While Running This Query Declare @Currentdate Datetime Set @Currentdate = Getdate() Select Count(Id) from Dbo. tblLstOfClientHolidays...
I am getting the error while running this query
declare @currentDate datetime
set @currentDate = getdate()
select count(Id)
from dbo.tblLstOfClientHolidays
where Datetime(@currentDate) = CONVERT(VARCHAR(10),getdate(ClientHoldiday),10)
2 Answers
Select
count(Id)
From
dbo.tblLstOfClientHolidays
Where
CONVERT(VARCHAR(10),ClientHoldiday,10) = CONVERT(VARCHAR(10),@currentDate,10)
Since you are using SQL Server 2008, You can even CONVERT to DATE rather than converting to a VARCHAR and then doing a comparison.
DECLARE @currentDate DATE;
SET @currentDate = GETDATE();
SELECT count(Id)
FROM dbo.tblLstOfClientHolidays
WHERE CONVERT(DATE,@currentDate) = CONVERT(DATE,ClientHoldiday);