‘EXTRACT’ is not a recognized built-in function name.

Recently, I was working on a requirement to extract the year from a date in SQL Server. After executing the SQL query, I got this error.

‘EXTRACT’ is not a recognized built-in function name.

I was executing the following query.

SELECT 
    sale_Date,
    EXTRACT(YEAR FROM sale_Date) AS SalesYear
FROM 
    Sales
WHERE 
    EXTRACT(YEAR FROM sale_Date) BETWEEN 2020 AND 2025;

After executing the above query, I got this error as shown in the screenshot below.

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

Solution

We can fix this error using the DATEPART function instead of the EXTRACT function using the query below.

SELECT 
    sale_Date,
    DATEPART(YEAR, sale_Date) AS SalesYear
FROM 
    Sales
WHERE 
    DATEPART(YEAR, sale_Date) BETWEEN 2020 AND 2025;

I got the expected output as shown in the screenshot below.

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

You may also like the following articles.