Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'DATE' is not a recognized built-in function name

I wish to find all records of the current day. I have a field Date of type DATE. I am getting error on sql server

'DATE' is not a recognized built-in function name.

on this line

(DATE(EnterDate) = CURDATE() )
like image 671
Engineer M Sajjad Avatar asked Jan 07 '14 13:01

Engineer M Sajjad


2 Answers

As the error states, there is no DATE function in SQL Server 2008 or 2012 (you tagged both so I'm not sure which you're targeting). You can, however, cast to a date type in SQL Server 2008 and above:

WHERE EnterDate = CONVERT(date,GETDATE())

Note that there's no CURDATE function either, so I've translated that to GETDATE()

like image 164
D Stanley Avatar answered Oct 02 '22 03:10

D Stanley


Use the following condition in your where cluase

WHERE CAST(DateColumn AS DATE) = CAST(GETDATE() AS DATE)
              ^------------ Your Column Name with `Date` or 'DateTime'  data type

CURDATE() is a mysql function, In Sql-Server we have GETDATE() function to get current date and time.

like image 26
M.Ali Avatar answered Oct 02 '22 04:10

M.Ali