Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Operand type clash: date is incompatible with int

$
0
0

declare @FromDate date ='2014-01-20'
declare @ToDate date ='2014-01-28'
declare @query  AS NVARCHAR(MAX)

set @query = 'select * from TimeSheet  
where  TimeSheet.TaskDate between '+CAST(@FromDate as NVARCHAR(MAX))+' and '+CAST(@ToDate as NVARCHAR(MAX))

exec(@query)

when I run the query , I get the following error "Operand type clash: date is incompatible with int" .

how Can I solve it ?


ASk


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>