Recently, as a SQL Server developer, I was required to retrieve yesterday’s Date. I was working on that requirement. I was using the CAST() for this purpose. After executing a SQL query using the CAST() function, I encountered this error. In this article, we will discuss how to fix the error operand type clash date is incompatible with int.
Fix: Operand Type Clash: Date Is Incompatible With Int
I executed the following query to retrieve yesterday’s date in SQL Server.
SELECT CAST(CURRENT_TIMESTAMP AS Date) - 1 AS YesterdayDateOnlyAfter executing the above query, I encountered the error shown in the screenshot below.

Solution
Now, let’s discuss multiple solutions to resolve this error.
Solution-1
Here, we will use the DATEADD() function along with the CAST() function to obtain the required output.
SELECT DATEADD(day, -1, CAST(CURRENT_TIMESTAMP AS DATE)) AS YesterdayDateOnlyOr,
SELECT DATEADD(day, -1, CAST(GETDATE() AS DATE)) AS YesterdayDateOnlyAfter executing the above query, I got the expected output as per the screenshot below.


Or, you can also use the below query for the same output.
SELECT CAST(DATEADD(DAY, -1, GETDATE()) AS DATE) AS YesterdayDateOnlyWe successfully obtained the desired output, as shown in the screenshot below.

Solution-2
We can execute the query below to retrieve yesterday’s date with time.
SELECT CAST(CURRENT_TIMESTAMP AS datetime) - 1 AS YesterdayDatewithtimeAfter executing the above query, we got the expected output as shown in the screenshot below.

Alternatively, you can use the query below without the CAST() function.
SELECT CURRENT_TIMESTAMP - 1 AS YesterdayWithTimeRefer to the screenshot below, which displays the expected output.

Video Tutorial
You may also like the following articles.
- The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
- SQL Server Get UTC Date
- Trunc Date In SQL Server
- SQL Server Date Compare
- SQL Server DateTime To Date
After working for more than 15 years in the Software field, especially in Microsoft technologies, I have decided to share my expert knowledge of SQL Server. Check out all the SQL Server and related database tutorials I have shared here. Most of the readers are from countries like the United States of America, the United Kingdom, New Zealand, Australia, Canada, etc. I am also a Microsoft MVP. Check out more here.