I am using SQL Server 2008 with a C# Windows Forms application. The products table has other values along with the expiry date and I want to show ProductID, ProductName, AvailableQuantity, and ExpiryDate in a grid so I can allow users to get an idea of items which are getting expired before the due date.
The purpose is to add only those products to that grid whose expiry date is getting closer, i.e. which are getting expired in 2 months.
I have tried using the TRUNC function like as follow:
select *
from tblProducts
where DateExpiry < TRUNC( SYSDATE ) + INTERVAL '62' DAY;
but I am getting the following error in SQL Server 2008:
Msg 195, Level 15, State 10, Line 1
'TRUNC' is not a recognized built-in function name.
Why I am getting this error? I have seen online that the same code is working fine, however, it is generating the error in my case. Is there any other way that can fulfill my requirements? Or do I have to modify the query somehow, which can help me resolve my error?