Suraj Binorkar Suraj Binorkar - 6 days ago 5
SQL Question

Why I am getting this Error : "columname is not a defined system type" in SQL Server 2008?

I wanted to check the records from back 10 days to current date when I was trying to run this query:

select top 1 *
from tbl_refrence_master
where ref_id='4110118488'
and CONVERT(date, ref_entry_date) between DATEADD(day, -10, convert(ref_entry_date, GETDATE()))
and CONVERT(date, getdate())


But I'm getting this error:


Type ref_entry_date is not a defined system type.


I can do the same through my source code but I wanted to do by this SQL query.
Why I am getting this error?

Answer
SELECT top 1 * 
FROM tbl_refrence_master 
WHERE ref_id='4110118488'
    AND ISDATE(ref_entry_date) = 1 
    AND DATEDIFF(d,ref_entry_date,GETDATE()) BETWEEN 0 AND 10
Comments